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

Trying to fetch "http://" succeeds (!?) #40

Closed
bos opened this issue Mar 31, 2014 · 10 comments
Closed

Trying to fetch "http://" succeeds (!?) #40

bos opened this issue Mar 31, 2014 · 10 comments

Comments

@bos
Copy link
Contributor

bos commented Mar 31, 2014

This behaviour makes no sense to me.

The issue seems to be that parseUrl returns a Request with an empty host field, and this gets interpreted as localhost when it should be rejected, as e.g. curl does:

$ curl http://
curl: (6) Could not resolve host: http; nodename nor servname provided, or not known
@snoyberg
Copy link
Owner

I can't reproduce over here. With this program:

import Network.HTTP.Client

main :: IO ()
main = do
    man <- newManager defaultManagerSettings
    req <- parseUrl "http://"
    res <- httpLbs req man
    print res

I get:

InternalIOException getAddrInfo: does not exist (No address associated with hostname)

Does this snippet make a successful request on your system?

@bos
Copy link
Contributor Author

bos commented Mar 31, 2014

See also curl http://:80, because who wants consistency anyway?

$ curl http://:
<html><body><h1>It works!</h1></body></html>

@bos
Copy link
Contributor Author

bos commented Mar 31, 2014

Yes, it successfully runs a HTTP request against localhost on my Mac.

@bos
Copy link
Contributor Author

bos commented Mar 31, 2014

I would guess that the proximal cause is a difference in the behaviour of getaddrinfo on different platforms. On Linux, it says "don't be so stupid", whereas OS X says "have another hit on the bong, dude!"

snoyberg added a commit that referenced this issue Mar 31, 2014
@snoyberg
Copy link
Owner

Does ac48ffa restore sanity?

@bos
Copy link
Contributor Author

bos commented Apr 1, 2014

It does, thanks.

@bos bos closed this as completed Apr 1, 2014
@bos
Copy link
Contributor Author

bos commented Apr 1, 2014

Please let me know when you issue a point release that contains this fix, so I can update my deps. Thanks again!

@snoyberg
Copy link
Owner

snoyberg commented Apr 1, 2014

Version 0.2.3 is now on Hackage. If I can ask, what made you notice this strange behavior?

@bos
Copy link
Contributor Author

bos commented Apr 1, 2014

I'm writing a wrapper library for http-client, and I discovered this by accident while writing a unit test.

@snoyberg
Copy link
Owner

snoyberg commented Apr 1, 2014

Ahh, cool. Nice name :)

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

2 participants