pngwn HF staff commited on
Commit
ec0346c
1 Parent(s): 029b549

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -133,23 +133,17 @@ async def proxy_to_node(
133
  f"Total setup time before streaming: {time.time() - start_time:.4f} seconds"
134
  )
135
 
136
- req = client.build_request("GET", httpx.URL(url), headers=headers)
137
  r = await client.send(req)
138
  print(f"Time to prepare request: {time.time() - start_time:.4f} seconds")
139
 
140
  print(f"\nHeaders: {r.headers}\n")
141
 
142
- # new_headers = {
143
- # key: value
144
- # for key, value in r.headers.items()
145
- # if key.lower() != "content-length"
146
- # }
147
-
148
- # new_headers["Transfer-Encoding"] = "chunked"
149
- body = await r.body()
150
-
151
- return Response(body, headers=r.headers)
152
-
153
 
154
  @app.api_route(
155
  "/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
 
133
  f"Total setup time before streaming: {time.time() - start_time:.4f} seconds"
134
  )
135
 
136
+ req = client.build_request(request.method, httpx.URL(url), headers=headers)
137
  r = await client.send(req)
138
  print(f"Time to prepare request: {time.time() - start_time:.4f} seconds")
139
 
140
  print(f"\nHeaders: {r.headers}\n")
141
 
142
+ return Response(
143
+ content=r.content,
144
+ status_code=r.status_code,
145
+ headers=dict(r.headers),
146
+ )
 
 
 
 
 
 
147
 
148
  @app.api_route(
149
  "/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]