1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/test_http10.rb
MSP-Greg b6ef31ef7d
[bug] Fixup SERVER_PROTOCOL & HTTP_VERSION headers (#2871)
* Fixup SERVER_PROTOCOL & HTTP_VERSION headers

HTTP_VERSION header can be defined by a client, but it's also used by Rack, Rails, Sinatra, etc.  Change c/ragel code to set SERVER_PROTOCOL to the HTTP protocol defined by the request 'first line', and for now, set HTTP_VERSION to the same.

Note that previously SERVER_PROTOCOL was set to http/1.1, which has been since the start of Puma.

* Tests - replace HTTP_VERSION with SERVER_PROTOCOL
2022-09-09 21:05:19 -05:00

27 lines
844 B
Ruby

require_relative "helper"
require "puma/puma_http11"
class Http10ParserTest < Minitest::Test
def test_parse_simple
parser = Puma::HttpParser.new
req = {}
http = "GET / HTTP/1.0\r\n\r\n"
nread = parser.execute(req, http, 0)
assert nread == http.length, "Failed to parse the full HTTP request"
assert parser.finished?, "Parser didn't finish"
assert !parser.error?, "Parser had error"
assert nread == parser.nread, "Number read returned from execute does not match"
assert_equal '/', req['REQUEST_PATH']
assert_equal 'HTTP/1.0', req['SERVER_PROTOCOL']
assert_equal '/', req['REQUEST_URI']
assert_equal 'GET', req['REQUEST_METHOD']
assert_nil req['FRAGMENT']
assert_nil req['QUERY_STRING']
parser.reset
assert parser.nread == 0, "Number read after reset should be 0"
end
end