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

Endpoints don't handle chunked request bodies correctly #102

Closed
rdlowrey opened this issue Jun 24, 2013 · 3 comments
Closed

Endpoints don't handle chunked request bodies correctly #102

rdlowrey opened this issue Jun 24, 2013 · 3 comments

Comments

@rdlowrey
Copy link

I don't have much experience with WSGI, but this may be a simple fix as per a similar issue over at StackOverflow.

Endpoints do not appear to handle chunked request bodies correctly. The following is a raw request message to demonstrate and the corresponding raw response message ...

Request

POST /post HTTP/1.1
Host: httpbin.org
User-Agent: Artax/0.3.0-devel (PHP5.4+)
Transfer-Encoding: chunked

4
test
0

Response

HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 24 Jun 2013 17:23:18 GMT
Server: gunicorn/0.17.4
Content-Length: 297
Connection: keep-alive

{
  "origin": "66.57.216.51",
  "files": {},
  "form": {},
  "url": "http://httpbin.org/post",
  "args": {},
  "headers": {
    "Transfer-Encoding": "chunked",
    "Host": "httpbin.org",
    "Connection": "close",
    "User-Agent": "Artax/0.3.0-devel (PHP5.4+)"
  },
  "json": null,
  "data": ""
}

As you can see, the response is unaware of the request's body data.

@Keno
Copy link

Keno commented May 10, 2014

Just ran into this issue as well.

@tomviner
Copy link
Contributor

This looks like it's fixed now:

In [11]: requests.post(
    'https://httpbin.org/post', 
    data='4\r\ntest\r\n0\r\n\r\n', 
    headers={'Transfer-Encoding': 'chunked'}).json()
Out[11]: 
{u'args': {},
 u'data': u'test',
 u'files': {},
 u'form': {},
 u'headers': {u'Accept': u'*/*',
  u'Accept-Encoding': u'gzip, deflate',
  u'Content-Length': u'4',
  u'Host': u'httpbin.org',
  u'User-Agent': u'python-requests/2.6.0 CPython/2.7.8 Linux/4.4.0-43-generic'},
 u'json': None,
 u'origin': u'x.x.x.x',
 u'url': u'https://httpbin.org/post'}

@sigmavirus24
Copy link
Contributor

I can verify @tomviner is correct. Looks like whatever proxy sits in front of the httpbin app is taking care of this (hence why there's no Transfer-Encoding: chunked header)

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

No branches or pull requests

5 participants