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: ReadResponse should return ErrUnexpectedEOF on truncated response #6564

Closed
gopherbot opened this issue Oct 10, 2013 · 11 comments
Closed
Milestone

Comments

@gopherbot
Copy link

by manoj.dayaram@moovweb.com:

I'm trying to use the net/http package to Get a page from the following site:

http://www.whitecap.com

However, whenever I do, I get an EOF error.  I tried curling the page and it looks fine:

$ curl -v http://www.whitecap.com
* About to connect() to www.whitecap.com port 80 (#0)
*   Trying 65.248.165.82... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1
zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: www.whitecap.com
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location:
http://www.whitecap.com/webapp/wcs/stores/servlet/TopCategoriesDisplay?storeId=11301&;langId=-1&catalogId=11101
* Connection #0 to host www.whitecap.com left intact
* Closing connection #0

I have a feeling that this might be because the 301 response from the server does not
include a trailing "\r\n" at the end of the response.  However, curl and
browsers are able to handle this response, I figured Go should be able to as well.


What steps will reproduce the problem?
  1.  Run this program locally (to use http package):
      http://play.golang.org/p/K71wCu2vnr


What is the expected output?
  The redirect should succeed and it should print out the body of
  http://www.whitecap.com/webapp/wcs/stores/servlet/TopCategoriesDisplay?storeId=11301&;langId=-1&catalogId=11101

What do you see instead?
  panic: Get http://www.whitecap.com: EOF

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

Which operating system are you using?
  Linux, but seeing the same behavior in Mac OSX

Which version are you using?  (run 'go version')
  I tried go1.0.3 and go1.2rc1, same problem in each.
@adg
Copy link
Contributor

adg commented Oct 11, 2013

Comment 1:

Here's an example that doesn't require the network: http://play.golang.org/p/D1j0gSu-6Z
That web server is just broken. I don't think we should support this. Leaving for Brad
to decide, though.

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 2:

This server declares itself as "IBM_HTTP_Server".  I've never heard of it.
We could in theory work around this, but I'd rather not.  If it were some popular HTTP
server, that'd be more compelling.  But I don't want to encourage non-compliance.  Or it
were something harmless, sure, but "fixing" this would mean real failures slipped
through undetected.
Perhaps the error we should return is UnexpectedEOF, though.

@gopherbot
Copy link
Author

Comment 3 by covener:

The "IBM_HTTP_Server" header indicates that it's IBM's binary distribution of Apache
HTTP Server, bundled with a number of commercial products.  IHS for short.
But the HTTP/0.9 response on http://www.whitecap.com/ does not seem to be from the same
server that responds to other requests.  Even if you send HTTP/1.1 without a Host:
header, it returns the same HTTP/0.9 redirect.
IOW I think it's some other non-Apache based proxy server doing that HTTP/0.9 redirect,
and a backend IHS doing normal responses after the redirect (with Server: header
preserved by the weird proxy)

@gopherbot
Copy link
Author

Comment 4 by covener:

I should have clarified that an Apache based server would return 400 for HTTP/1.1 w/o a
Host header, which was the point of that test.

@gopherbot
Copy link
Author

Comment 5 by covener:

Sorry -- And I guess http/0.9 is misleading. It's just a weird response that an Apache
based server would not generate.

@rsc
Copy link
Contributor

rsc commented Oct 15, 2013

Comment 6:

Let's fix the error being returned and leave it at that.

Labels changed: added priority-later, go1.3, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added release-go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 8:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 9:

Labels changed: added repo-main.

@bradfitz
Copy link
Contributor

Comment 10:

Sent https://golang.org/cl/52420043

Status changed to Started.

@bradfitz
Copy link
Contributor

Comment 11:

This issue was closed by revision 89c9d6b.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 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