-
Notifications
You must be signed in to change notification settings - Fork 193
Add content-length header for http2 connections #208
base: development
Are you sure you want to change the base?
Conversation
Thanks for this @natemara! The test troubles are interesting, I've got a suspicion they're timing related, but I'll try to take a look and see if I can fix them so that we can write some tests for this. |
Yes, I'm working on the development branch, with up to #205. |
Hmm, that's perplexing. What's your environment? What Python are you using, what OpenSSL etc.? |
@natemara Do you want to try rebasing onto the current development branch and try again? |
If a body is defined, we should be sending a Content-Length header unless the request has the Transfer-Encoding header is set. This should fix #206.
Alright, that's rebased and checking now. |
Ok, so this is doing better. There are two things that need to be solved:
Both of those will need to be fixed up. =) You up for doing that @natemara? |
@@ -170,6 +170,8 @@ def request(self, method, url, body=None, headers={}): | |||
# Convert the body to bytes if needed. | |||
if body and isinstance(body, (unicode, bytes)): | |||
body = to_bytestring(body) | |||
if 'Transfer-Encoding' not in headers.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we need O(n) here? Would it be better to just use:
if 'Transfer-Encoding' not in headers:
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change hyper can work with Jetty HTTP/2 server.
If a body is defined, we should be sending a Content-Length header unless the request has the Transfer-Encoding header is set. This should fix #206. I was having some difficulty running the tests, but it seems like that was mostly related to SSL certificate problems. Looking at the spec doc, it says that clients SHOULD send the Content-Length header when there is no Transfer-Encoding header set.