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

requests library seems to ignore "Transfer-Encoding" header #6760

Closed
Green360 opened this issue Jul 6, 2024 · 1 comment
Closed

requests library seems to ignore "Transfer-Encoding" header #6760

Green360 opened this issue Jul 6, 2024 · 1 comment
Labels
actions/autoclose-qa Used for automation to auto-close an issue Question/Not a bug

Comments

@Green360
Copy link

Green360 commented Jul 6, 2024

I wanted to send a request with "Transfer-Encoding:chunked" but somehow the header is never set.
Below is my code for testing and the corresponding captured request.

import requests

url = 'http://[replaced]/test.php'

def data_chunks():
    yield b'7\r\n'
    yield b'param=2\r\n'

response = requests.post(url,data=data_chunks(), headers={"Transfer-Encoding":"chunked", "Content-Type":"application/x-www-form-urlencoded"}, proxies={"http":"http://127.0.0.1:8080"})

POST /test.php HTTP/1.1
Host: [replaced]
User-Agent: python-requests/2.28.1
Accept-Encoding: gzip, deflate, br
Accept: /
Connection: close
Content-Length: 12

7
param=2

If I do not set the "Transfer-Encoding" header it is not used and even if I explicitly set the "Transfer-Encoding" header it is not used. The requests library always seems to put a "Content-Length" instead.
My goal is to form this request:

POST /test.php HTTP/1.1
Host: [replaced]
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded

7
param=2

@sigmavirus24 sigmavirus24 added Question/Not a bug actions/autoclose-qa Used for automation to auto-close an issue labels Jul 7, 2024
Copy link

github-actions bot commented Jul 7, 2024

As described in the template, we won't be able to answer questions on this issue tracker. Please use Stack Overflow

@github-actions github-actions bot closed this as completed Jul 7, 2024
@github-actions github-actions bot locked as off-topic and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
actions/autoclose-qa Used for automation to auto-close an issue Question/Not a bug
Projects
None yet
Development

No branches or pull requests

2 participants