Skip to content
Browse files

don't fix the host header if it's not set right, the port is set auto…

…matically via the server port info, no need to parse the headers for that
  • Loading branch information...
1 parent 0643eff commit 8441f2554d461ebdb810c576da2410b665f9ba42 @mattetti mattetti committed Feb 21, 2011
Showing with 4 additions and 10 deletions.
  1. +1 −1 examples/hello_world.rb
  2. +3 −9 lib/goliath/request.rb
View
2 examples/hello_world.rb
@@ -7,4 +7,4 @@ class HelloWorld < Goliath::API
def response(env)
[200, {}, "hello world"]
end
-end
+end
View
12 lib/goliath/request.rb
@@ -50,8 +50,6 @@ class Request
PATH_INFO = 'PATH_INFO'.freeze
FRAGMENT = 'FRAGMENT'.freeze
- HOST_PORT_REGEXP = /(?<host>.*?):(?<port>.*)/
-
def initialize(options = {})
@body = StringIO.new(INITIAL_BODY.dup)
@env = Goliath::Env.new
@@ -71,13 +69,9 @@ def initialize(options = {})
@parser.on_message_complete = proc { @state = :finished }
@parser.on_headers_complete = proc do |h|
- # Extract the server port if defined in the host
- m = HOST_PORT_REGEXP.match(h['Host'])
- if m && m[:host]
- h['Host'] = m[:host]
- @env[SERVER_PORT] ||= m[:port]
- end
-
+ # Note that in some cases, the Host header includes the port.
+ # Goliath sets its port directly based on the server info instead
+ # of relying on the response parsing.
h.each do |k, v|
@env[HTTP_PREFIX + k.gsub('-','_').upcase] = v
end

0 comments on commit 8441f25

Please sign in to comment.
Something went wrong with that request. Please try again.