Skip to content

Commit 1e4d255

Browse files
committed
Merge branch 'master' of github.com:DataDog/dd-apm-test-agent into sabrenner/remove-vcr-handling
2 parents 392830f + c59e636 commit 1e4d255

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

ddapm_test_agent/vcr_proxy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async def _request(
290290

291291
response = Response(body=provider_response.content, status=provider_response.status_code)
292292
response_headers = provider_response.headers
293-
293+
294294
_write_response_headers(response, response_headers)
295295

296296
return response
@@ -329,7 +329,8 @@ async def proxy_request(
329329
)
330330

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

334335
request_kwargs: Dict[str, Any] = {
335336
"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
@@ -195,3 +195,10 @@ async def test_vcr_proxy_does_not_record_ignored_headers(
195195
assert "User-Super-Secret-Api-Key" not in recorded_request["request"]["headers"]
196196
assert "Foo-Bar" not in recorded_request["request"]["headers"]
197197
assert "Authorization" not in recorded_request["request"]["headers"]
198+
199+
200+
async def test_vcr_proxy_with_chunked_request(agent: TestClient[Any, Any], vcr_cassettes_directory: str) -> None:
201+
resp = await agent.post("/vcr/custom/serve", json={"foo": "bar"}, chunked=True)
202+
203+
assert resp.status == 200
204+
assert await resp.text() == "OK"

0 commit comments

Comments
 (0)