Skip to content

Commit ffa7bf6

Browse files
committed
fix: apigateway async proxy _adapt_response content type translation
1 parent df695f7 commit ffa7bf6

File tree

1 file changed

+3
-4
lines changed
  • src/sentry/hybridcloud/apigateway_async

1 file changed

+3
-4
lines changed

src/sentry/hybridcloud/apigateway_async/proxy.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging
99
from collections.abc import AsyncGenerator, AsyncIterator
1010
from urllib.parse import urljoin, urlparse
11-
from wsgiref.util import is_hop_by_hop
1211

1312
import httpx
1413
from asgiref.sync import sync_to_async
@@ -75,8 +74,9 @@ async def _stream_response_and_close(response: httpx.Response) -> AsyncGenerator
7574
def _adapt_response(response: httpx.Response, remote_url: str) -> StreamingHttpResponse:
7675
"""Convert an httpx Response into a Django response."""
7776

77+
if content_type := response.headers.get("Content-Type", None):
78+
del response.headers["Content-Type"]
7879
new_headers = clean_outbound_headers(response.headers)
79-
content_type = new_headers.pop("Content-Type", None)
8080

8181
streamed_response = StreamingHttpResponse(
8282
streaming_content=_stream_response_and_close(response),
@@ -85,8 +85,7 @@ def _adapt_response(response: httpx.Response, remote_url: str) -> StreamingHttpR
8585
)
8686

8787
for header, value in new_headers.items():
88-
if not is_hop_by_hop(header):
89-
streamed_response[header] = value
88+
streamed_response[header] = value
9089

9190
streamed_response[PROXY_DIRECT_LOCATION_HEADER] = remote_url
9291
return streamed_response

0 commit comments

Comments
 (0)