Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/core/azure-core/azure/core/pipeline/transport/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ async def open(self):
if not self.session and self._session_owner:
self.session = aiohttp.ClientSession(
loop=self._loop,
trust_env=self._use_env_settings
trust_env=self._use_env_settings,
skip_auto_headers=['Content-Type']
)
if self.session is not None:
await self.session.__aenter__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ async def test_basic_aiohttp():
assert sender.session is None
assert response.status_code == 200

@pytest.mark.asyncio
async def test_aiohttp_auto_headers():

request = HttpRequest("POST", "https://www.bing.com/")
async with AioHttpTransport() as sender:
response = await sender.send(request)
auto_headers = response.internal_response.request_info.headers
assert 'Content-Type' not in auto_headers

@pytest.mark.asyncio
async def test_basic_async_requests():

Expand Down Expand Up @@ -77,4 +86,4 @@ async def do():
assert response.body() is not None

response = trio.run(do)
assert response.status_code == 200
assert response.status_code == 200
7 changes: 7 additions & 0 deletions sdk/core/azure-core/tests/test_requests_universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ def thread_body(local_sender):
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(thread_body, sender)
assert future.result()

def test_requests_auto_headers():
request = HttpRequest("POST", "https://www.bing.com/")
with RequestsTransport() as sender:
response = sender.send(request)
auto_headers = response.internal_response.request.headers
assert 'Content-Type' not in auto_headers