Repository navigation
Conversation
An empty Host was parsed with SERVER_NAME left nil, and the server answered 500 once the application noticed.
The Host value was optional in practice: a blank one left the request host nil. That is a 400, and the error is no longer rewritten as a bad URI.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #175.
Host:(a space, which the header parser strips to an empty value) was parsed as a request withhostandSERVER_NAMEboth nil. Rack::Lint then raised becauseSERVER_NAMEwas missing, and WEBrick reported that as 500. The same happened for a Host value that is not a host (not a host).A present Host that does not parse is now
WEBrick::HTTPStatus::BadRequest(400,invalid host). A request with no Host header still uses the server name, and a normal Host is unchanged. The bad-request error is not rewritten asbad URI.Before the change,
GET / HTTP/1.1withHost:parsed andmeta_vars["SERVER_NAME"]was nil. After it, parsing raisesWEBrick::HTTPStatus::BadRequest400, and a listening server answersHTTP/1.1 400.Host: test.examplestill setsSERVER_NAMEtotest.example.ruby -Ilib:test/lib -rhelper test/webrick/test_httprequest.rb: 34 tests, 171 assertions, 0 failures.ruby -Ilib:test/lib -rhelper test/webrick/test_httpserver.rb: 15 tests, 161 assertions, 0 failures.