forked from loafle/openapi-generator-original
[python] check output content-type only if preload_content is set (#7847)
This commit is contained in:
parent
739249917c
commit
b3bc926b1d
@ -200,8 +200,6 @@ class ApiClient(object):
|
|||||||
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
content_type = response_data.getheader('content-type')
|
|
||||||
|
|
||||||
self.last_response = response_data
|
self.last_response = response_data
|
||||||
|
|
||||||
return_data = response_data
|
return_data = response_data
|
||||||
@ -218,6 +216,7 @@ class ApiClient(object):
|
|||||||
|
|
||||||
if six.PY3 and response_type not in ["file", "bytes"]:
|
if six.PY3 and response_type not in ["file", "bytes"]:
|
||||||
match = None
|
match = None
|
||||||
|
content_type = response_data.getheader('content-type')
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
||||||
encoding = match.group(1) if match else "utf-8"
|
encoding = match.group(1) if match else "utf-8"
|
||||||
|
@ -191,8 +191,6 @@ class ApiClient(object):
|
|||||||
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
content_type = response_data.getheader('content-type')
|
|
||||||
|
|
||||||
self.last_response = response_data
|
self.last_response = response_data
|
||||||
|
|
||||||
return_data = response_data
|
return_data = response_data
|
||||||
@ -204,6 +202,7 @@ class ApiClient(object):
|
|||||||
|
|
||||||
if six.PY3 and response_type not in ["file", "bytes"]:
|
if six.PY3 and response_type not in ["file", "bytes"]:
|
||||||
match = None
|
match = None
|
||||||
|
content_type = response_data.getheader('content-type')
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
||||||
encoding = match.group(1) if match else "utf-8"
|
encoding = match.group(1) if match else "utf-8"
|
||||||
|
@ -192,8 +192,6 @@ class ApiClient(object):
|
|||||||
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
content_type = response_data.getheader('content-type')
|
|
||||||
|
|
||||||
self.last_response = response_data
|
self.last_response = response_data
|
||||||
|
|
||||||
return_data = response_data
|
return_data = response_data
|
||||||
@ -205,6 +203,7 @@ class ApiClient(object):
|
|||||||
|
|
||||||
if six.PY3 and response_type not in ["file", "bytes"]:
|
if six.PY3 and response_type not in ["file", "bytes"]:
|
||||||
match = None
|
match = None
|
||||||
|
content_type = response_data.getheader('content-type')
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
||||||
encoding = match.group(1) if match else "utf-8"
|
encoding = match.group(1) if match else "utf-8"
|
||||||
|
@ -190,8 +190,6 @@ class ApiClient(object):
|
|||||||
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
content_type = response_data.getheader('content-type')
|
|
||||||
|
|
||||||
self.last_response = response_data
|
self.last_response = response_data
|
||||||
|
|
||||||
return_data = response_data
|
return_data = response_data
|
||||||
@ -203,6 +201,7 @@ class ApiClient(object):
|
|||||||
|
|
||||||
if six.PY3 and response_type not in ["file", "bytes"]:
|
if six.PY3 and response_type not in ["file", "bytes"]:
|
||||||
match = None
|
match = None
|
||||||
|
content_type = response_data.getheader('content-type')
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
||||||
encoding = match.group(1) if match else "utf-8"
|
encoding = match.group(1) if match else "utf-8"
|
||||||
|
@ -190,8 +190,6 @@ class ApiClient(object):
|
|||||||
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
e.body = e.body.decode('utf-8') if six.PY3 else e.body
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
content_type = response_data.getheader('content-type')
|
|
||||||
|
|
||||||
self.last_response = response_data
|
self.last_response = response_data
|
||||||
|
|
||||||
return_data = response_data
|
return_data = response_data
|
||||||
@ -203,6 +201,7 @@ class ApiClient(object):
|
|||||||
|
|
||||||
if six.PY3 and response_type not in ["file", "bytes"]:
|
if six.PY3 and response_type not in ["file", "bytes"]:
|
||||||
match = None
|
match = None
|
||||||
|
content_type = response_data.getheader('content-type')
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
|
||||||
encoding = match.group(1) if match else "utf-8"
|
encoding = match.group(1) if match else "utf-8"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user