#87 ✓resolved
Andreas Karlsson

Missing SERVER_NAME if Host header is missing

Reported by Andreas Karlsson | November 9th, 2008 @ 02:08 PM | in 1.1

Rack::Lint complains about missing requried env key SERVER_NAME when the host field is left out.

The host header is required in HTTP 1.1, but not in HTTP 1.0. According to the Rack spec http://rack.rubyforge.org/doc/files/SPEC.html the SERVER_NAME key is required, but I am not sure what it should be if no hostname is specified in the HTTP request.

The error message is:

!! Unexpected error while processing request: env missing required key SERVER_NAME

Steps to reproduce.

Use the Rack application below.

# hello_world.ru
app = proc do |env|
  [200, {'Content-Type' => 'text/plain'}, ["Hello World!\n"]]
end

use Rack::Lint

run app
thin start -R hello_world.ru

I personally use netcat to send my HTTP requests but if you do not have it installed telnet works just fine, if a bit more tedious.

echo -e -n 'GET / HTTP/1.0\r\n\r\n' | netcat localhost 3000

This is request does not give any errors:

echo -e -n 'GET / HTTP/1.0\r\nHost: localhost\r\n\r\n' | netcat localhost 3000

Comments and changes to this ticket

  • macournoyer

    macournoyer November 10th, 2008 @ 09:16 AM

    • Milestone changed from Future to 1.1
    • State changed from “new” to “open”

    defaulting to localhost sounds like the most obvious thing to do.

    thx for reporting Andreas!

  • macournoyer

    macournoyer December 16th, 2008 @ 09:06 PM

    • State changed from “open” to “resolved”

    (from [7c8e416848e2dfc8f1fb594997be640cf8f398b2]) Defaults SERVER_NAME to localhost like webrick does [#87 state:resolved] http://github.com/macournoyer/th...

  • macournoyer

    macournoyer March 16th, 2009 @ 09:45 PM

    (from [af9b7d0b755a4622a73b4e461a06934d0b9449d7]) Merge branch 'master' of git://github.com/macournoyer/thin into async_for_rack

    • 'master' of git://github.com/macournoyer/thin: Add hostingrails to users page changelog entry for last patch thin.c#http_field : omit parsing #defined string Defaults SERVER_NAME to localhost like webrick does [#87 state:resolved] Add changelog entry for last merge Fix spec failing cause of newer version of Ragel skiping some useless chars when parsing. dont need to namespace macros regen parser with namespaced functions just making sure to namespace the parser requiring mongrel breaks the tests namepsacing namespacing ragel stuff Add gemspec file for github No need for COMMITTERS file anymore Update site users page http://github.com/macournoyer/th...
  • John

    John November 29th, 2023 @ 03:42 PM

    Moim skromnym zdaniem, Nie wszystkie kasyna internetowe są wspaniałe. Jestem przekonany, że kasyno internetowe mr bet kasyno uczyni twoje życie lepszym, ponieważ jego celem nie jest kradzież pieniędzy, ale bycie z tobą szczerym,Nie mogłem uwierzyć, że mogę zarabiać pieniądze z zabawy. Poza tym to niesamowite, że nie muszę pracować cały dzień, żeby mieć wystarczająco dużo pieniędzy. https://mrbet-casino.pl/

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Referenced by

Pages