Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

How to https? #408

Open
peterbe opened this issue Apr 24, 2019 · 5 comments
Open

How to https? #408

peterbe opened this issue Apr 24, 2019 · 5 comments

Comments

@peterbe
Copy link

peterbe commented Apr 24, 2019

Consider

from hyper import HTTPConnection
c = HTTPConnection('www.peterbe.com')
c.request('GET', '/')
resp = c.get_response()
print(resp.status)
print(resp.headers['location'])

Output becomes:

301
[b'https://www.peterbe.com/']

That's like doing curl -v http://www.peterbe.com which will also respond with:

< HTTP/1.1 301 Moved Permanently
< Server: cloudflare-nginx
< Date: Wed, 24 Apr 2019 13:32:25 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
< Location: https://www.peterbe.com/

I think the problem is that http://www.peterbecom is HTTP/1.1 whereas https://www.peterbe.com is HTTP/2. ...if that matters.

@peterbe
Copy link
Author

peterbe commented Apr 24, 2019

PS the immediate "solution" is to do it like this instead:

-c = HTTPConnection('www.peterbe.com',)
+c = HTTPConnection('www.peterbe.com', port=443)

then it works as expected. Clunky though. That's why I think this issue should stay open till it's less clunky.

The documentation says:

By default, all HTTP/2 connections are made over TLS.

@peterbe
Copy link
Author

peterbe commented May 2, 2019

@Asmeble How does that help when trying to use hyper?

Also, how is that different from regular requests?

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

No branches or pull requests

2 participants
@peterbe and others