I just ran into a stupid client that put the username in the http_URL field, making the first line of the HTTP request look like this:
GET http://usern...@localhost:8080/mojombo/grit HTTP/1.1 Unicorn 500s on this, saying it can't parse the headers. I'm including a unit test that will die on this, but my question is should Unicorn handle this gracefully by just stripping off the username - parsing it as a 'server' instead of a 'host'? It seems that most other webservers do, even though it doesn't appear to be the spec. Thanks, Scott --- test/unit/test_http_parser.rb | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb index 1b3faaf..7d32e5e 100644 --- a/test/unit/test_http_parser.rb +++ b/test/unit/test_http_parser.rb @@ -298,6 +298,24 @@ class HttpParserTest < Test::Unit::TestCase assert ! parser.keepalive? end + # some dumb clients add users because they're stupid + def test_absolute_uri_w_user + parser = HttpParser.new + req = {} + http = "GET http://[email protected]/foo?q=bar HTTP/1.0\r\n\r\n" + assert_equal req, parser.headers(req, http) + assert_equal 'http', req['rack.url_scheme'] + assert_equal '/foo?q=bar', req['REQUEST_URI'] + assert_equal '/foo', req['REQUEST_PATH'] + assert_equal 'q=bar', req['QUERY_STRING'] + + assert_equal 'example.com', req['HTTP_HOST'] + assert_equal 'example.com', req['SERVER_NAME'] + assert_equal '80', req['SERVER_PORT'] + assert_equal "", http + assert ! parser.keepalive? + end + def test_absolute_uri parser = HttpParser.new req = {} -- 1.6.6.rc1 _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
