Internal Server Error 500 when Empty Host Header Sent
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 327
- Fork
- 113
- Merge medio
- 4h 2m
- PR unite (30g)
- 1
Descrizione
Overview
When sent a GET request with an empty host header, WEBrick responds with error code 500, but it should respond with Error Code 400, for an invalid request.
Reproducing the Bug
- Clone, build, and install WEBrick. (Tested on ea124002ee5ff43b6cf846931b2cb898b3f47819)
- Set up a
config.rufile with the following contents:
class Server
def call(env)
[200, {}, []]
end
end
run Server.new
- Run
rackup. - Send a GET request with an empty host header, and observe WEBrick's response as follows:
printf 'GET / HTTP/1.1\r\nHost: \r\n\r\n' | ncat localhost 9292
Rack::Lint::LintError: env missing required key SERVER_NAME (Rack::Lint::LintError)
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/lint.rb:283:in `block in check_environment'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/lint.rb:282:in `each'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/lint.rb:282:in `check_environment'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/lint.rb:63:in `response'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/lint.rb:41:in `call'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/show_exceptions.rb:31:in `call'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/common_logger.rb:43:in `call'
/usr/share/rubygems-integration/all/gems/rack-3.1.16/lib/rack/content_length.rb:20:in `call'
/usr/share/rubygems-integration/all/gems/rackup-2.1.0/lib/rackup/handler/webrick.rb:111:in `service'
/var/lib/gems/3.3.0/gems/webrick-1.9.1/lib/webrick/httpserver.rb:140:in `service'
/var/lib/gems/3.3.0/gems/webrick-1.9.1/lib/webrick/httpserver.rb:96:in `run'
/var/lib/gems/3.3.0/gems/webrick-1.9.1/lib/webrick/server.rb:310:in `block in start_thread'
::1 - - [27/Aug/2025:18:40:52 +0000] "GET / HTTP/1.1" 500 1183 0.0002
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci la richiesta utilizzando la configurazione config.ru mostrata e un header Host vuoto, quindi segui la richiesta attraverso httpserver.rb di WEBrick e il gestore rackup menzionato nello stack trace. Conferma che la richiesta malformata attualmente raggiunge Rack con un SERVER_NAME mancante e che il comportamento finale è una risposta HTTP 400 invece di 500.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- backend, networking
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100