mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Ensure env[QUERY_STRING] is not set to nil when there is no query. (#1259)
* Ensure env[QUERY_STRING] is not set to nil when there is no query. In my application, sending a request like "GET http://example.dev:20557/ HTTP/1.1" would cause "Rack::Lint::LintError: env variable QUERY_STRING has non-string value nil" and eventually "Read error: #<NoMethodError: undefined method `empty?' for nil:NilClass>", due to there being no query string in the "full host request header." * Explain why we should only set a non-nil env value.
This commit is contained in:
parent
20d552a1e3
commit
de870595d0
1 changed files with 3 additions and 1 deletions
|
@ -522,7 +522,9 @@ module Puma
|
|||
|
||||
raise "No REQUEST PATH" unless env[REQUEST_PATH]
|
||||
|
||||
env[QUERY_STRING] = uri.query
|
||||
# A nil env value will cause a LintError (and fatal errors elsewhere),
|
||||
# so only set the env value if there actually is a value.
|
||||
env[QUERY_STRING] = uri.query if uri.query
|
||||
end
|
||||
|
||||
env[PATH_INFO] = env[REQUEST_PATH]
|
||||
|
|
Loading…
Reference in a new issue