Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/webrick/httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,22 +488,26 @@ def parse_uri(str, scheme="http")
str.sub!(%r{\A/+}o, '/')
uri = URI::parse(str)
return uri if uri.absolute?
uri.scheme = @forwarded_proto || scheme
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this line was moved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need the scheme to use URI.parse in my universe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore that - not needed - will fix

if @forwarded_host
host, port = @forwarded_host, @forwarded_port
elsif self["host"]
pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/n
host, port = *self['host'].scan(pattern)[0]
host, port = parse_host_request_line(self["host"], uri.scheme)
elsif @addr.size > 0
host, port = @addr[2], @addr[1]
else
host, port = @config[:ServerName], @config[:Port]
end
uri.scheme = @forwarded_proto || scheme
uri.host = host
uri.port = port ? port.to_i : nil
return URI::parse(uri.to_s)
end

def parse_host_request_line(host, _scheme)
pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/no
host.scan(pattern)[0]
end

def read_body(socket, block)
return unless socket
if tc = self['transfer-encoding']
Expand Down