lucky0146 commited on
Commit
9805c9f
·
verified ·
1 Parent(s): 5e8530e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -65,11 +65,18 @@ async def proxy(path: str, request: Request):
65
  follow_redirects=True
66
  )
67
 
68
- # Create response with same status code, headers, and content
 
 
 
 
 
 
 
69
  return Response(
70
  content=response.content,
71
  status_code=response.status_code,
72
- headers=dict(response.headers),
73
  )
74
  except httpx.RequestError as exc:
75
  raise HTTPException(status_code=503, detail=f"Error forwarding request: {str(exc)}")
 
65
  follow_redirects=True
66
  )
67
 
68
+ # Create response with same status code and content, but filter headers
69
+ # Remove problematic headers that could cause Content-Length issues
70
+ response_headers = dict(response.headers)
71
+ # Remove content-length header to let FastAPI calculate it correctly
72
+ response_headers.pop("content-length", None)
73
+ # Also remove transfer-encoding as it can conflict with content-length
74
+ response_headers.pop("transfer-encoding", None)
75
+
76
  return Response(
77
  content=response.content,
78
  status_code=response.status_code,
79
+ headers=response_headers,
80
  )
81
  except httpx.RequestError as exc:
82
  raise HTTPException(status_code=503, detail=f"Error forwarding request: {str(exc)}")