Skip to content

Commit

Permalink
fix request content encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostousov committed Nov 19, 2021
1 parent 2f72c17 commit dacc7a4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- master

env:
VEKTONN_PYTHON_PACKAGE_VERSION: 0.5.2
VEKTONN_PYTHON_PACKAGE_VERSION: 0.5.3

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions src/vektonn/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class VektonnAsync:
_request_headers = {
'Accept': 'application/json',
'Content-type': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
}

def __init__(self, base_url: str):
Expand Down Expand Up @@ -43,7 +43,7 @@ async def _post(
query_dto: VektonnBaseModel,
result_dto_type: Optional[Type[VektonnBaseModel]] = None
) -> Optional[VektonnBaseModel]:
request_content = query_dto.json()
request_content = query_dto.json().encode('utf-8')
async with ClientSession() as requests:
async with requests.post(url, headers=self._request_headers, data=request_content) as response:
if self._is_successful(response):
Expand Down
4 changes: 2 additions & 2 deletions src/vektonn/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Vektonn:
_request_headers = {
'Accept': 'application/json',
'Content-type': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
}

def __init__(self, base_url: str):
Expand Down Expand Up @@ -44,7 +44,7 @@ def _post(
query_dto: VektonnBaseModel,
result_dto_type: Optional[Type[VektonnBaseModel]] = None
) -> Optional[VektonnBaseModel]:
request_content = query_dto.json()
request_content = query_dto.json().encode('utf-8')
response = requests.post(url, headers=self._request_headers, data=request_content)

if self._is_successful(response):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_upload__success(vektonn_client: Vektonn):
attributes=[
AttributeDto(key='Id', value=AttributeValueDto(int64=42)),
AttributeDto(key='SplitId', value=AttributeValueDto(bool=True)),
AttributeDto(key='Payload', value=AttributeValueDto(string='la-la-la')),
AttributeDto(key='Payload', value=AttributeValueDto(string='la-la-la and some unicode chars Ὀδύσσεια 曳航')),
],
is_deleted=True,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def test_upload__success(vektonn_client_async: VektonnAsync):
attributes=[
AttributeDto(key='Id', value=AttributeValueDto(int64=42)),
AttributeDto(key='SplitId', value=AttributeValueDto(bool=True)),
AttributeDto(key='Payload', value=AttributeValueDto(string='la-la-la')),
AttributeDto(key='Payload', value=AttributeValueDto(string='la-la-la and some unicode chars Ὀδύσσεια 曳航')),
],
is_deleted=True,
)
Expand Down

0 comments on commit dacc7a4

Please sign in to comment.