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

fix ndjson parsing in Python client #40

Merged
merged 2 commits into from
Oct 10, 2023
Merged

Conversation

keith-hall-vmp
Copy link
Contributor

httpx is using the stdlib splitlines method for aiter_lines, but the NDJSON spec states that only \n (0x0A) should be treated as a line separator when parsing NDJSON.

This meant that if the server response contains other characters considered to be line separators by the Python stdlib, it would fail to correctly parse the (ND)JSON. So we fix this by copying the LineDecoder and modifying it to keep the line "ends" and then stitch the lines back together with the ends if the end is not \n.

@keith-hall-vmp keith-hall-vmp merged commit 097f5ca into main Oct 10, 2023
1 check passed
@keith-hall-vmp keith-hall-vmp deleted the python/fix-ndjson-parsing branch October 10, 2023 07:43
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

Successfully merging this pull request may close these issues.

2 participants