Internal Server Error 500 when Empty Host Header Sent
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby
- Domain
- backend, networking
Research direction
Reproduce the request using the shown config.ru setup and empty Host header, then trace the request through WEBrick's httpserver.rb and the rackup handler mentioned in the stack trace. Confirm that the malformed request currently reaches Rack with a missing SERVER_NAME and that the completed behavior is an HTTP 400 response instead of 500.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Ruby
- Stars
- 327
- Forks
- 113
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/webrick
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·