Recalculate content-length

It is needed according to
https://github.com/django/django/blob/master/django/middleware/gzip.py#L46

This was giving an issue because the content-length changes when is compressed by pipeline.

I have also added tests.