Skip to content

Commit c59e636

Browse files
fix(vcr): ignore Transfer-Encoding in proxied requests (#257)
1 parent fd46ab6 commit c59e636

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

ddapm_test_agent/vcr_proxy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ async def proxy_request(
465465
)
466466

467467
target_url = _url_path_join(provider_base_urls[provider], remaining_path)
468-
headers = {key: value for key, value in request.headers.items() if key != "Host"}
468+
skip_headers = {"host", "transfer-encoding"}
469+
headers = {key: value for key, value in request.headers.items() if not (key.lower() in skip_headers)}
469470

470471
request_kwargs: Dict[str, Any] = {
471472
"method": request.method,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Ignores the Transfer-Encoding header in proxied vcr requests, forwarding this header can lead to failures in
5+
downstream services.

tests/test_vcr_proxy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,10 @@ async def test_vcr_proxy_converts_legacy_vcr_cassette_to_json(
276276
assert os.path.exists(os.path.join(vcr_cassettes_directory, "custom", cassette_file))
277277

278278
assert not os.path.exists(vcr_legacy_cassette)
279+
280+
281+
async def test_vcr_proxy_with_chunked_request(agent: TestClient[Any, Any], vcr_cassettes_directory: str) -> None:
282+
resp = await agent.post("/vcr/custom/serve", json={"foo": "bar"}, chunked=True)
283+
284+
assert resp.status == 200
285+
assert await resp.text() == "OK"

0 commit comments

Comments
 (0)