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

Add content-length header for http2 connections #208

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open

Add content-length header for http2 connections #208

wants to merge 1 commit into from

Conversation

lily-mara
Copy link

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.

@Lukasa
Copy link
Member

Lukasa commented Mar 2, 2016

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.

@Lukasa
Copy link
Member

Lukasa commented Mar 2, 2016

Ok, so I can't reproduce your testing problems locally, and I believe I fixed all the relevant problems in #202. Does your local branch contain #202?

@lily-mara
Copy link
Author

Yes, I'm working on the development branch, with up to #205.

@Lukasa
Copy link
Member

Lukasa commented Mar 2, 2016

Hmm, that's perplexing. What's your environment? What Python are you using, what OpenSSL etc.?

@Lukasa
Copy link
Member

Lukasa commented Mar 23, 2016

@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.
@lily-mara
Copy link
Author

Alright, that's rebased and checking now.

@Lukasa
Copy link
Member

Lukasa commented Mar 24, 2016

Ok, so this is doing better. There are two things that need to be solved:

  • we need to update the tests (see the Python 2 result for some problems)
  • the function doesn't work as expected on Python 3 (for boring string type reasons)

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():

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:
    ....

Copy link

@michal-niklas michal-niklas left a 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.

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

Successfully merging this pull request may close these issues.

Problem sending JSON data as request body
4 participants