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: post to malformed URL gives wrong error #4271

Closed
rsc opened this issue Oct 21, 2012 · 10 comments
Closed

net/http: post to malformed URL gives wrong error #4271

rsc opened this issue Oct 21, 2012 · 10 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Oct 21, 2012

Trying an http.Post to the obviously wrong URL:
https:///Users/rsc/googlecode.upload.googlecode.com/files

returns this error:
dial tcp <nil>:443: connection refused

I assume the host name lookup for "Users" failed, but that should have been
the error instead of invoking dial.
Perhaps this bug is in net as opposed to net/http.
@rsc
Copy link
Contributor Author

rsc commented Dec 9, 2012

Comment 1:

I wonder if I really meant http:/// or http:// (three or two slashes).
With three slashes it is clearly net/http's fault - no host at all.
With two slashes it should say tcp Users:443, which I think it would.
So I am assuming this bug is the 3-slash problem, which is not net's.
It might be in url instead of http.

@rsc
Copy link
Contributor Author

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-m.

@rsc
Copy link
Contributor Author

rsc commented Dec 10, 2012

Comment 3:

Labels changed: added suggested.

@gopherbot
Copy link

Comment 4 by alakriti:

It seems to me the issue here is in net/url.  RFC 3986 Section 3.2.2
(http://tools.ietf.org/html/rfc3986#section-3.2.2) states:
If the URI scheme defines a default for host, then that default applies when the host
subcomponent is undefined or when the registered name is empty (zero length).  For
example, the "file" URI scheme is defined so that no authority, an empty host, and
localhost" all mean the end-user's machine, whereas the "http" scheme considers a
missing authority or empty host invalid.
So if the scheme is http or https and we have 3-slashes, we have a missing host, so we
should be returning an error from url.Parse
I'd be happy to submit a patch if you agree.

@rsc
Copy link
Contributor Author

rsc commented Dec 12, 2012

Comment 5:

Brad, do you think url.Parse should reject http:///file, or should the http client be in
charge of checking Host != "" before dialing?

@bradfitz
Copy link
Contributor

Comment 6:

Let's make the HTTP client check that anyway.  I'll defer to others on what is correct
URL-wise.

@bradfitz
Copy link
Contributor

Comment 7:

This issue was updated by revision f85b94a.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6931052

@bradfitz
Copy link
Contributor

Comment 8:

Russ, I think this bug is fixed, but maybe you want to do more here.
Leaving for you to close.

Status changed to Fixed.

@bradfitz
Copy link
Contributor

Comment 9:

Whoops, I closed it on accident anyway.

@rsc
Copy link
Contributor Author

rsc commented Dec 13, 2012

Comment 10:

lgtm

@rsc rsc added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Dec 13, 2012
@rsc rsc self-assigned this Dec 13, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

3 participants