Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Add 'patch_vary_headers' to middleware.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishbah committed Sep 28, 2014
1 parent f3af95f commit 7fdc37a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions responsive/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re

from django.template.loader import render_to_string
from django.utils.cache import patch_vary_headers
from django.utils.encoding import force_text

from .conf import settings
Expand Down Expand Up @@ -56,6 +57,8 @@ def process_response(self, request, response):
pattern = re.compile(b'<head>', re.IGNORECASE)
response.content = pattern.sub(b'<head>' + snippet, force_text(response.content))

if response.get('Content-Length', None):
response['Content-Length'] = len(response.content)
if response.get('Content-Length', None):
response['Content-Length'] = len(response.content)

patch_vary_headers(response, ('Cookie', ))
return response

0 comments on commit 7fdc37a

Please sign in to comment.