Puma: HTTP parse error, malformed request

2019-09-09 21:09发布

问题:

Firing up my local server with foreman and I get the following whenever I make any request.

HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
ENV: {"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.9.1", "GATEWAY_INTERFACE"=>"CGI/1.2"}

Running Ruby 2.2.0 with rvm

And some potentially relevant bits from my Gemfile:

gem 'rails', '4.2.5.2'
gem 'puma', '2.9.1'

Completely stumped here and would appreciate any help. Happy to provide more context from my config, but I don't even know where to start.

Edit:

I get this error when I run the server with foreman start. If I fire it up with rails s then all is well.

回答1:

Not sure if you found the cause of this one, but the underlining issue seems to be with '%' characters in the url.

I tried upgrading to the latest version of Puma '3.4.0' but was still able to reproduce the error.

Hopefully that helps you to replicate your issue. Will update when I find a fix.



回答2:

Make sure you're using http:// and not https://