Skip to content

Commit 1221efb

Browse files
committedJan 6, 2018
Don't require content for 201 and 202 status codes
Fixes mvantellingen#613
1 parent 1d746ae commit 1221efb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
 

‎src/zeep/wsdl/bindings/soap.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ def process_reply(self, client, operation, response):
131131
:type response: requests.Response
132132
133133
"""
134-
if response.status_code != 200 and not response.content:
134+
if response.status_code in (201, 202) and not response.content:
135+
return None
136+
137+
elif response.status_code != 200 and not response.content:
135138
raise TransportError(
136139
u'Server returned HTTP status %d (no content available)'
137140
% response.status_code,

‎tests/test_wsdl_soap.py

+32
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,35 @@ def test_unexpected_headers():
382382
assert result.body.price == 120.123
383383
assert result.header.body is None
384384
assert len(result.header._raw_elements) == 1
385+
386+
387+
def test_response_201():
388+
client = Client('tests/wsdl_files/soap_header.wsdl')
389+
binding = client.service._binding
390+
391+
response = stub(
392+
status_code=201,
393+
content='',
394+
encoding='utf-8',
395+
headers={}
396+
)
397+
398+
result = binding.process_reply(
399+
client, binding.get('GetLastTradePrice'), response)
400+
assert result is None
401+
402+
403+
def test_response_202():
404+
client = Client('tests/wsdl_files/soap_header.wsdl')
405+
binding = client.service._binding
406+
407+
response = stub(
408+
status_code=202,
409+
content='',
410+
encoding='utf-8',
411+
headers={}
412+
)
413+
414+
result = binding.process_reply(
415+
client, binding.get('GetLastTradePrice'), response)
416+
assert result is None

0 commit comments

Comments
 (0)