Skip to content

Commit c026f1e

Browse files
authored
[python] don't send content-type when no request body (#3181)
* Update dependencies * Update dependencies (2025-08-20 07:05:18) * Regenerate for typespec-python (2025-08-20 07:10:21) * Regenerate for autorest.python (2025-08-20 07:26:32) * Update dependencies * Update dependencies (2025-08-20 08:40:21) * Regenerate for typespec-python (2025-08-20 08:45:17) * Regenerate for autorest.python (2025-08-20 09:01:46) * Update dependencies * Update dependencies (2025-08-20 11:18:46) * Regenerate for typespec-python (2025-08-20 11:23:56) * Regenerate for autorest.python (2025-08-20 11:40:51) * Update dependencies * Update dependencies (2025-08-21 08:34:49) * Regenerate for autorest.python (2025-08-21 08:55:54) * Update dependencies * Update dependencies (2025-08-21 09:51:56) * Regenerate for typespec-python (2025-08-21 09:56:47) * Regenerate for autorest.python (2025-08-21 10:12:56) * Update dependencies * Update dependencies (2025-08-22 01:28:18) * Regenerate for typespec-python (2025-08-22 01:33:36) * Regenerate for autorest.python (2025-08-22 01:50:51) * Update dependencies * Update dependencies (2025-08-22 02:22:35) * Regenerate for typespec-python (2025-08-22 02:27:38) * Regenerate for autorest.python (2025-08-22 02:44:07) * add changelog --------- Co-authored-by: AutoPrFromHttpClientPython <AutoPrFromHttpClientPython>
1 parent 2bcb33f commit c026f1e

126 files changed

Lines changed: 1357 additions & 556 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
changeKind: fix
3+
packages:
4+
- "@autorest/python"
5+
- "@azure-tools/typespec-python"
6+
---
7+
8+
don't send content-type when no request body

packages/autorest.python/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
3131
"dependencies": {
32-
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTIzMzU2Mi9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.2.tgz",
32+
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTI0ODczMy9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.2.tgz",
3333
"@autorest/system-requirements": "~1.0.2",
3434
"fs-extra": "~11.2.0",
3535
"tsx": "~4.19.1"

packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/_operations/_operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ def _basic_polling_initial(
9191
_params = kwargs.pop("params", {}) or {}
9292

9393
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
94+
content_type = content_type if product else None
9495
cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)
9596

96-
content_type = content_type or "application/json"
97+
content_type = content_type or "application/json" if product else None
9798
_json = None
9899
_content = None
99100
if isinstance(product, (IOBase, bytes)):
@@ -233,6 +234,7 @@ def begin_basic_polling(
233234
_params = kwargs.pop("params", {}) or {}
234235

235236
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
237+
content_type = content_type if product else None
236238
cls: ClsType[JSON] = kwargs.pop("cls", None)
237239
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
238240
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)

packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/aio/_operations/_operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ async def _basic_polling_initial(
6262
_params = kwargs.pop("params", {}) or {}
6363

6464
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
65+
content_type = content_type if product else None
6566
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
6667

67-
content_type = content_type or "application/json"
68+
content_type = content_type or "application/json" if product else None
6869
_json = None
6970
_content = None
7071
if isinstance(product, (IOBase, bytes)):
@@ -204,6 +205,7 @@ async def begin_basic_polling(
204205
_params = kwargs.pop("params", {}) or {}
205206

206207
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
208+
content_type = content_type if product else None
207209
cls: ClsType[JSON] = kwargs.pop("cls", None)
208210
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
209211
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ async def _test_lro_initial(
122122
_params = kwargs.pop("params", {}) or {}
123123

124124
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
125+
content_type = content_type if product else None
125126
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
126127

127-
content_type = content_type or "application/json"
128+
content_type = content_type or "application/json" if product else None
128129
_json = None
129130
_content = None
130131
if isinstance(product, (IOBase, bytes)):
@@ -220,6 +221,7 @@ async def begin_test_lro(
220221
_params = kwargs.pop("params", {}) or {}
221222

222223
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
224+
content_type = content_type if product else None
223225
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
224226
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
225227
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ def _test_lro_initial(
201201
_params = kwargs.pop("params", {}) or {}
202202

203203
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
204+
content_type = content_type if product else None
204205
cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)
205206

206-
content_type = content_type or "application/json"
207+
content_type = content_type or "application/json" if product else None
207208
_json = None
208209
_content = None
209210
if isinstance(product, (IOBase, bytes)):
@@ -296,6 +297,7 @@ def begin_test_lro(
296297
_params = kwargs.pop("params", {}) or {}
297298

298299
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
300+
content_type = content_type if product else None
299301
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
300302
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
301303
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ async def test_two(
111111

112112
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2.0.0"))
113113
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
114+
content_type = content_type if parameter_one else None
114115
cls: ClsType[_models.ModelTwo] = kwargs.pop("cls", None)
115116

116-
content_type = content_type or "application/json"
117+
content_type = content_type or "application/json" if parameter_one else None
117118
_json = None
118119
_content = None
119120
if isinstance(parameter_one, (IOBase, bytes)):

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ def test_two(
154154

155155
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2.0.0"))
156156
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
157+
content_type = content_type if parameter_one else None
157158
cls: ClsType[_models.ModelTwo] = kwargs.pop("cls", None)
158159

159-
content_type = content_type or "application/json"
160+
content_type = content_type or "application/json" if parameter_one else None
160161
_json = None
161162
_content = None
162163
if isinstance(parameter_one, (IOBase, bytes)):

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ async def test_two(
192192

193193
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "3.0.0"))
194194
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
195+
content_type = content_type if parameter_one else None
195196
cls: ClsType[_models.ModelThree] = kwargs.pop("cls", None)
196197

197-
content_type = content_type or "application/json"
198+
content_type = content_type or "application/json" if parameter_one else None
198199
_json = None
199200
_content = None
200201
if isinstance(parameter_one, (IOBase, bytes)):

packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def test_four(self, input: Optional[Union[_models.SourcePath, IO[bytes]]]
110110

111111
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "3.0.0"))
112112
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
113+
content_type = content_type if input else None
113114
cls: ClsType[None] = kwargs.pop("cls", None)
114115

115116
_json = None
@@ -121,7 +122,7 @@ async def test_four(self, input: Optional[Union[_models.SourcePath, IO[bytes]]]
121122
_json = self._serialize.body(input, "SourcePath")
122123
else:
123124
_json = None
124-
content_type = content_type or "application/json"
125+
content_type = content_type or "application/json" if input else None
125126

126127
_request = build_test_four_request(
127128
api_version=api_version,

0 commit comments

Comments
 (0)