Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP element HEADER is longer than the (1024 * (80 + 32)) allowed length #179

Closed
betelgeuse opened this issue Dec 30, 2012 · 19 comments
Closed

Comments

@betelgeuse
Copy link

Trying puma on my rails 3.1.8 app I get:

$ ./script/rails s puma -b localhost
=> Booting Puma
=> Rails 3.1.8 application starting in development on http://localhost:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 2.0.0.b4 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
2012-12-30 18:55:51 +0200: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element HEADER is longer than the (1024 * (80 + 32)) allowed length.>
2012-12-30 18:55:51 +0200: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>true, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.0.0.b4", "GATEWAY_INTERFACE"=>"CGI/1.2"}

The request is just a simple request with curl so the headers shouldn't be too long:

$ curl -vi http://localhost:3000
* About to connect() to localhost port 3000 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.28.1
> Host: localhost:3000
> Accept: */*
> 
< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
* no chunk, no close, no size. Assume close to signal end

< 
* Closing connection #0
@leehambley
Copy link

I have the same, I couldn't diagnose it; I've temporarily switched to thin, it's only a development question.

@evanphx
Copy link
Member

evanphx commented Mar 19, 2013

What version of ruby? I'm not able to diagnose the issue at preset.

@betelgeuse
Copy link
Author

@evanphx MRI 1.9.3

@leehambley
Copy link

Same p194

Sent from my Galaxy S3.
On 20 Mar 2013 20:30, "Petteri Räty" notifications@github.com wrote:

@evanphx https://github.com/evanphx MRI 1.9.3


Reply to this email directly or view it on GitHubhttps://github.com//issues/179#issuecomment-15198114
.

@evanphx
Copy link
Member

evanphx commented Jul 4, 2013

Is this still happening? I was never able to replicate the issue.

@leehambley
Copy link

I moved away from Puma, Evan. Please feel free to close it, I'll come and reopen whenever I can reproduce, if ever!

@betelgeuse
Copy link
Author

MRI 2.0.0p195 with puma 2.2.2 on rails 3.2.12 does not show the issue. Testing some other combos.

@betelgeuse
Copy link
Author

Still an issue with MRI 1.9.3:

$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0]
$ ./script/rails s puma -b localhost 
=> Booting Puma
=> Rails 3.2.12 application starting in development on http://localhost:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 2.2.2 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
2013-07-05 16:30:18 +0300: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element HEADER is longer than the (1024 * (80 + 32)) allowed length.>
2013-07-05 16:30:18 +0300: ENV: {"rack.version"=>[1, 1], "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.2.2", "GATEWAY_INTERFACE"=>"CGI/1.2"}

@evanphx
Copy link
Member

evanphx commented Jul 6, 2013

@betelgeuse What was the request you sent?

@betelgeuse
Copy link
Author

The same as in original report.

On 6.7.2013, at 7.39, Evan Phoenix notifications@github.com wrote:

@betelgeuse What was the request you sent?


Reply to this email directly or view it on GitHub.

@samflores
Copy link

I'm facing the same problem in a Sinatra application. In my environment the issue only happens when I require the rugged gem, even if I do nothing with the lib.

Here's an application that reproduces the problem: https://github.com/samflores/puma_issue_179

@betelgeuse
Copy link
Author

My app also loads rugged so maybe that is not a coincidence.

On 18.7.2013, at 19.17, Samuel Flores notifications@github.com wrote:

I'm facing the same problem in a Sinatra application. In my environment the issue only happens when I require the rugged gem, even if I do nothing with the lib.

Here's an application that reproduces the problem: https://github.com/samflores/puma_issue_179


Reply to this email directly or view it on GitHub.

@evanphx
Copy link
Member

evanphx commented Jul 18, 2013

It was not a coincidence. Rugged loads an extension which contains the symbol http_parser_init. This is the same symbol name that puma's parser uses. And because dynamic linking is a pain in the ass, when puma invoked http_parser_init, it didn't invoke it's own function by that name but the one that was loaded from rugged. Those 2 functions obviously don't do the same thing and thus the struct was corrupt for puma and it resulted in this obscure error.

Morale of the story: beware dynamic linking.

@samflores
Copy link

Thanks for the quick solution! ❤️ ❤️

@mgharbik
Copy link

I am not using rugged but my server raises the same error when sending a post request, it's curious because this happens only when the request contains a full base64 code of a file. Any suggestions?

Full error:

2014-10-31 07:17:30 +0100: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element HEADER is longer than the (1024 * (80 + 32)) allowed length (was 116736) >
2014-10-31 07:17:30 +0100: ENV: {"rack.version"=>[1, 2], "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", "REQUEST_METHOD"=>"POST", "REQUEST_PATH"=>"/developers/offers"}
---

@brianlaw033
Copy link

I’m running into the same issue as @mgharbik
Any solutions?

@nateberkopec
Copy link
Member

@brianlaw033 This is a really old issue, please open a new one with a reproduction case.

@wellington1993
Copy link

I have the same problem:

2018-08-24 12:11:06 -0300: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element HEADER is longer than the (1024 * (80 + 32)) allowed length (was 115340)>

Yes, I'm receiving large headers.. Can I solve this?

Thanks!

@sekmo
Copy link

sekmo commented Jan 14, 2019

Did you happen to run a workaround for these long GET requests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants