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

net/http: malformed HTTP request when GET follows HEAD request #5522

Closed
davecheney opened this issue May 21, 2013 · 5 comments
Closed

net/http: malformed HTTP request when GET follows HEAD request #5522

davecheney opened this issue May 21, 2013 · 5 comments

Comments

@davecheney
Copy link
Contributor

Issue report from user via golang-nuts:
https://groups.google.com/d/msg/golang-nuts/h7RrDiFx0uo/uenFHfqot_AJ

What steps will reproduce the problem?

Compile and run http://play.golang.org/p/fI1wA1Uq4A

What is the expected output?

http://javascript.ru HEAD: OK
http://javascript.ru GET: OK
http://example.com HEAD: OK
http://example.com GET: OK

What do you see instead?

http://javascript.ru HEAD: OK
http://javascript.ru GET: Error: Get http://javascript.ru: malformed HTTP version
"\x1f\x8b\b\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00HTTP/1.1"
http://example.com HEAD: OK
http://example.com GET: Error: Get http://example.iana.org: EOF

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Ubuntu 13.04

* Also reproducible on Windows 7

Which version are you using?  (run 'go version')

go version go1.1 linux/amd64

* Also reproducible on: devel +c786b0f8eb4b Tue May 21 03:22:52 2013 +0800 windows/amd64

Please provide any additional information below.

The issue happens after sending a 'HEAD' request to a resource and then performing
another request. In the snippet above, I send 'HEAD' and then 'GET'. The same would be
if 'HEAD' after 'HEAD' is used. If 'HEAD' request is not used, then no such errors occur.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added priority-soon, go1.1.1, removed priority-triage.

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 2:

I don't believe either of those servers are speaking valid HTTP.
javascript.ru is sending a body in response to a HEAD request and example.iana.org is
replying with HTTP/1.1 200 OK and closing the connection immediately without sending a
"Connection: close" header (keep-alive is the default in HTTP/1.1 if not said otherwise).
HEAD / HTTP/1.1
Host: javascript.ru
Accept-Encoding: gzip
HTTP/1.1 200 OK
Server: nginx/1.2.1
Date: Tue, 21 May 2013 20:50:44 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: vblastvisit=1369169444; expires=Wed, 21-May-2014 20:50:44 GMT; path=/;
domain=.javascript.ru
Set-Cookie: vblastactivity=0; expires=Wed, 21-May-2014 20:50:44 GMT; path=/;
domain=.javascript.ru
Cache-Control: store, no-cache, must-revalidate
Pragma: private
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Tue, 21 May 2013 20:50:44 GMT
Cache-Control: post-check=0, pre-check=0
Content-Encoding: gzip
���(binary gibberish)
It looks like an nginx bug.
It at least does appear that nginx does the right thing if we don't send it a
"Accept-Encoding: gzip" header.  I can fix that at least.

@bradfitz
Copy link
Contributor

Comment 3:

I've filed http://trac.nginx.org/nginx/ticket/358#ticket

@bradfitz
Copy link
Contributor

Comment 4:

This issue was closed by revision ddda798.

Status changed to Fixed.

@ianlancetaylor
Copy link
Contributor

Comment 5:

Labels changed: removed go1.1.1.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants