1
0
Fork 0
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:
Jackson Ray Hamilton 2017-04-07 09:42:01 -07:00 committed by Nate Berkopec
parent 20d552a1e3
commit de870595d0

View file

@ -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]