Skip to content

Feature: implement steaming api responses#129

Merged
krishan711 merged 4 commits into
mainfrom
streaming
Mar 5, 2026
Merged

Feature: implement steaming api responses#129
krishan711 merged 4 commits into
mainfrom
streaming

Conversation

@krishan711
Copy link
Copy Markdown
Contributor

Description

Screenshots:

Checklist:

  • I have updated the CHANGELOG with a summary of my changes

Copilot AI review requested due to automatic review settings March 5, 2026 16:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit Content-Encoding: identity header to the NDJSON streaming route and validates it in the existing streaming-route test.

Changes:

  • Set Content-Encoding: identity on StreamingResponse returned by streaming_json_route.
  • Update the streaming route test to assert the new response header.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
core/api/streaming_json_route.py Adds an explicit Content-Encoding header to the streaming NDJSON response.
tests/api/test_streaming_json_route.py Extends the valid-body test to assert content-encoding is identity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/api/streaming_json_route.py Outdated
return StreamingResponse(
content=wrappedGenerator,
media_type='application/x-ndjson',
headers={'Content-Encoding': 'identity'},
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting Content-Encoding: identity is redundant (no encoding is the default when the header is absent) and can be misinterpreted by some HTTP clients/middleware as an actual encoding to decode. If the intent is to prevent response compression for streaming, prefer disabling compression at the middleware/server layer, or omit Content-Encoding and use a more appropriate directive (e.g., Cache-Control: no-transform) if you need to discourage intermediaries from transforming the payload.

Suggested change
headers={'Content-Encoding': 'identity'},

Copilot uses AI. Check for mistakes.
)
assert response.status_code == 200
assert response.headers["content-type"] == "application/x-ndjson"
assert response.headers["content-encoding"] == "identity"
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion bakes Content-Encoding: identity into the public contract of the route, even though the absence of the header already implies identity. This makes the test brittle and will fail if response compression is legitimately introduced later (or if the header is removed as redundant). Consider asserting that the response is not encoded (e.g., header missing or not equal to gzip/br), or omit this assertion unless callers truly require it.

Suggested change
assert response.headers["content-encoding"] == "identity"
content_encoding = response.headers.get("content-encoding", "").lower()
assert content_encoding not in ("gzip", "br")

Copilot uses AI. Check for mistakes.
@krishan711 krishan711 merged commit fc7afc1 into main Mar 5, 2026
4 checks passed
@krishan711 krishan711 deleted the streaming branch March 5, 2026 17:38
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