I have a python app which basically sends POST request to an external service and returns the response back. Its like a proxy basically. The external service sometimes returns compressed HTML response i.e. Content-Encoding:gzip and sometimes the response is plain HTML. I want to send the response back to the client from the python proxy without modifying it.
However the python requests library decompresses the response returned by external service if the response is compressed. I use the python requests library for sending POST request. Below is the code snippet.
response = requests.post(end_point, data=data, headers=headers)
return response
How do I ensure the response returned is not modified i.e. if external service returns compressed response we need to return compressed data in response and if external service returns uncompressed response we need to return uncompressed response.
Thanks, Prathik