Skip to content

sequence post give wrong content-type #117

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

Open
ghost opened this issue Mar 18, 2024 · 0 comments
Open

sequence post give wrong content-type #117

ghost opened this issue Mar 18, 2024 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 18, 2024

import tls_client
client = tls_client.Session()
print(client.post('https://httpbin.org/post', json={'a':'b'}).json()
{'args': {}, 'data': '{"a": "b"}', 'files': {}, 'form': {}, 'headers': {'Accept': '/', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Length': '10', 'Content-Type': 'application/json', 'Host': 'httpbin.org', 'User-Agent': 'tls-client/1.0.1', 'X-Amzn-Trace-Id': 'Root=1-65f57b99-62f659ac717afad079b6f9f6'}, 'json': {'a': 'b'}, 'origin': '24.6.214.76', 'url': 'https://httpbin.org/post'}
print(client.post('https://httpbin.org/post', data={'a':'b'}).json() # content-type show be application/x-www-form-urlencoded
{'args': {}, 'data': 'a=b', 'files': {}, 'form': {}, 'headers': {'Accept': '/', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Length': '3', 'Content-Type': 'application/json', 'Host': 'httpbin.org', 'User-Agent': 'tls-client/1.0.1', 'X-Amzn-Trace-Id': 'Root=1-65f57ba4-5caf4a7701cfc5eb735aac2d'}, 'json': None, 'origin': '24.6.214.76', 'url': 'https://httpbin.org/post'}

I already give a pull request in #116 to fix the problem

@ghost ghost mentioned this issue Dec 4, 2024
diprog added a commit to diprog/python-tls-client-async that referenced this issue May 12, 2025
…yte responses (e.g., images) by decoding base64 data)

This PR fixes an issue where binary responses (such as images) were not handled correctly in `python-tls-client-async`. Previously, the response body was treated as plain text, leading to corrupted data when downloading binary content like PNGs or PDFs.

The root cause was that the underlying Go library returns binary responses encoded in base64 if `isByteResponse=true`, but the Python code did not decode this properly.

This patch:
- Modifies `response.py` to split and decode base64-encoded bodies.
- Ensures correct handling of binary responses (e.g., images).
- Sets `"isByteResponse": True` in the session payload for consistency.

Related issues:
- FlorianREGAZ#83
- FlorianREGAZ#119
- FlorianREGAZ#117
- FlorianREGAZ#122

Thanks to @3droj7 for PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants