Skip to content

Commit

Permalink
fix CONNECT requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Franz committed Jun 21, 2016
1 parent 7a4a1d7 commit ae1cb02
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/icaprb/server/request_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,13 @@ def parse_http_request_line(line)
@length_read += line.length
str_method, str_uri, str_version = line.scan(/(GET|POST|PUT|DELETE|PATCH|OPTIONS|TRACE|HEAD|CONNECT) (\S+) HTTP\/([\d\.]+)/i).first
raise HTTP_Parse_Error.new 'invalid http Method' if str_method.nil?
uri = URI(str_uri)
unless str_method == 'CONNECT'
uri = URI(str_uri)
else
host,port = str_uri.split(':')
uri = URI::Generic.new(nil,nil,host,port,nil,nil,"#{host}:#{port}",nil,nil).to_s
end

unless str_method && uri && str_version
raise HTTP_Parse_Error.new 'The request line is not complete.'
end
Expand Down

0 comments on commit ae1cb02

Please sign in to comment.