0

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

Bourne
  • 1,905
  • 13
  • 35
  • 53
  • 1
    why are you not using a real proxy? – middlestump Jun 02 '16 at 01:29
  • @hichris123 How is it a duplicate. I want to understand how to return the raw response and not how to extract the data. The other thread does not say how to return the raw response – Bourne Jun 03 '16 at 21:43

0 Answers0