0

I want get size of http data responsed to the browser in django. how to do that.?

the destination i want is difference between gzip response and non-gzip response.

Jisson
  • 3,566
  • 8
  • 38
  • 71

1 Answers1

0

You can access the "Content-Length" header of the Response to see the size of the data in the body (See MDN :https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length)

However in Django it seems that this Content-Length header is set inside the CommonMiddleware, and thus the Content Length header can only be accessed after the response has been throught this Middelware. So there is two solutions here ;

  • Writing a custom MiddleWare to get the Content Lenght after the response has been throught Common Middleware
  • Hack some stuff with the renderer to get the len of the content.
  • Get the Content Length on Client Side

Some Reference ;

BDurand
  • 108
  • 1
  • 10