Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Missing SERVER_NAME if Host header is missing

#87

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

Reported by Andreas Karlsson · November 9th, 2008 @ 02:08 PM

State: resolved
Milestone: 1.1
Assigned to: macournoyer macournoyer

Activity

  1. macournoyer
    macournoyer
    • 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!

    November 10th, 2008 @ 09:16 AM

  2. macournoyer
    macournoyer
    • State changed from open to resolved

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

    December 16th, 2008 @ 09:06 PM

  3. macournoyer
    macournoyer

    (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 Missing SERVER_NAME if Host header is missing 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...

    March 16th, 2009 @ 09:45 PM

  4. John
    John

    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/

    November 29th, 2023 @ 03:42 PM

  5. Adriana
    Adriana

    Od dawna Lubię hazard, dla mnie jest to sposób na relaks po pracy, ale zawsze gram odpowiedzialnie, z limitami i bez złudzeń na łatwe pieniądze. Mogę doradzić sprawdzoną platformę do wyszukiwania wiarygodnych kasyn i automatów https://polscekasyno.pl/casino/fountain-casino/ Tutaj szczegółowo opisano Fountain Casino z bonusami bez depozytu, wsparciem dla polskich złotych i uczciwymi opiniami. Jest wygodny interfejs, szybkie wypłaty i wybór sprawdzonych gier od najlepszych dostawców, dzięki czemu możesz bezpiecznie przetestować automaty i wybrać odpowiedni dla swojego stylu.

    December 9th, 2025 @ 06:41 AM

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.