Add content-length header for http2 connections#208
Add content-length header for http2 connections#208lily-mara wants to merge 1 commit intopython-hyper:developmentfrom lily-mara:development
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? |
| # 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.
Any reason why we need O(n) here? Would it be better to just use:
if 'Transfer-Encoding' not in headers:
....
michal-niklas
left a comment
There was a problem hiding this comment.
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.