Sha256: aaefd8d1a181897e9b502905c3894f488737ee090cdffdb9c2ca245fc489c2dd
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'envoy/server/channel' module Envoy module Server module Web include EM::P::LineText2 def post_init @header = "" end def unbind @channel.trunk.channels.delete @channel.id if @channel end def receive_line line @header << line + "\r\n" if line =~ /^Host: ([^:]*)/ host = $1 raise "Request is not in #{@zone}" unless host.end_with?($zone) host = host[0...-$zone.length] host = host.split(".").last trunk = Trunk.trunks[host].sample || raise("No trunk for #{host}#{$zone}") @channel = Channel.new(trunk, self, @header) set_text_mode elsif @header.size > 4096 raise "Header's too long for my liking" end rescue RuntimeError => e send_data "HTTP/1.0 500 Internal Server Error\r\n" send_data "Content-Type: text/plain\r\n" send_data "\r\n" send_data "#{e.message}\r\n" close_connection true end def receive_binary_data data @channel.stream data end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
envoy-proxy-0.0.2 | lib/envoy/server/web.rb |
envoy-proxy-0.0.1 | lib/envoy/server/web.rb |