Peterase commited on
Commit
3be9e60
·
1 Parent(s): c48d01a

fix: remove Transfer-Encoding chunked (illegal in HTTP/2) from SSE response headers

Browse files
Files changed (1) hide show
  1. src/api/routes/rag.py +2 -4
src/api/routes/rag.py CHANGED
@@ -86,13 +86,11 @@ async def chat_with_rag_stream(
86
 
87
  user_id = current_user.id if current_user else None
88
 
89
- # SSE headers: X-Accel-Buffering: no is critical for HF Spaces nginx
90
- # to disable proxy buffering which causes ERR_HTTP2_PROTOCOL_ERROR
91
  headers = {
92
  "X-Accel-Buffering": "no",
93
  "Cache-Control": "no-cache, no-transform",
94
- "Connection": "keep-alive",
95
- "Transfer-Encoding": "chunked",
96
  }
97
 
98
  return StreamingResponse(
 
86
 
87
  user_id = current_user.id if current_user else None
88
 
89
+ # X-Accel-Buffering: no tells HF nginx NOT to buffer — fixes ERR_HTTP2_PROTOCOL_ERROR
90
+ # NOTE: Do NOT set Transfer-Encoding: chunked — it is prohibited in HTTP/2 (RFC 7540 §8.1.2.2)
91
  headers = {
92
  "X-Accel-Buffering": "no",
93
  "Cache-Control": "no-cache, no-transform",
 
 
94
  }
95
 
96
  return StreamingResponse(