Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into add_json_content

* 'main' of https://github.com/Azure/azure-sdk-for-python:
  Exclude azure-mgmt-videoanalyzer from docs onboarding (Azure#21564)
  [rest] fix str check in content kwarg to be six.string_types check for 2.7 (Azure#21550)
  • Loading branch information
iscai-msft committed Nov 3, 2021
2 parents 9431994 + a6991c8 commit 6fdd132
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function ValidatePackage($packageName, $packageVersion, $workingDirectory) {
}

$PackageExclusions = @{
'azure-mgmt-videoanalyzer' = 'Unsupported doc directives: https://github.com/Azure/azure-sdk-for-python/issues/21563';
'azure-mgmt-quota' = 'Unsupported doc directives: https://github.com/Azure/azure-sdk-for-python/issues/21366';
'azure-mgmt-webpubsub' = 'Unsupported doc directives https://github.com/Azure/azure-sdk-for-python/issues/21346';
'azure-mgmt-apimanagement' = 'Unsupported doc directives https://github.com/Azure/azure-sdk-for-python/issues/18084';
Expand Down
3 changes: 1 addition & 2 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
rather than silently truncating data in case the underlying tcp connection is closed prematurely.
(thanks to @jochen-ott-by for the contribution) #20412
- UnboundLocalError when SansIOHTTPPolicy handles an exception #15222

### Other Changes
- Add default content type header of `text/plain` and content length header for users who pass unicode strings to the `content` kwarg of `HttpRequest` in 2.7 #21550

## 1.19.1 (2021-11-01)

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/rest/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _shared_set_content_body(content):
if isinstance(content, ET.Element):
# XML body
return set_xml_body(content)
if isinstance(content, (str, bytes)):
if isinstance(content, (six.string_types, bytes)):
headers = {}
body = content
if isinstance(content, six.string_types):
Expand Down
11 changes: 11 additions & 0 deletions sdk/core/azure-core/tests/test_rest_http_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ def test_data_str_input():
assert len(request.headers) == 1
assert request.headers['Content-Type'] == 'application/x-www-form-urlencoded'

def test_content_str_input():
requests = [
HttpRequest("POST", "/fake", content="hello, world!"),
HttpRequest("POST", "/fake", content=u"hello, world!"),
]
for request in requests:
assert len(request.headers) == 2
assert request.headers["Content-Type"] == "text/plain"
assert request.headers["Content-Length"] == "13"
assert request.content == "hello, world!"

@pytest.mark.parametrize(("value"), (object(), {"key": "value"}))
def test_multipart_invalid_value(value):

Expand Down

0 comments on commit 6fdd132

Please sign in to comment.