@@ -31,57 +31,3 @@ def conditional_content_removal(request, response):
3131 if request .method == 'HEAD' :
3232 response .content = ''
3333 return response
34-
35- def fix_IE_for_attach (request , response ):
36- """
37- This function will prevent Django from serving a Content-Disposition header
38- while expecting the browser to cache it (only when the browser is IE). This
39- leads to IE not allowing the client to download.
40- """
41- useragent = request .META .get ('HTTP_USER_AGENT' , '' ).upper ()
42- if 'MSIE' not in useragent and 'CHROMEFRAME' not in useragent :
43- return response
44-
45- offending_headers = ('no-cache' , 'no-store' )
46- if response .has_header ('Content-Disposition' ):
47- try :
48- del response ['Pragma' ]
49- except KeyError :
50- pass
51- if response .has_header ('Cache-Control' ):
52- cache_control_values = [value .strip () for value in
53- response ['Cache-Control' ].split (',' )
54- if value .strip ().lower () not in offending_headers ]
55-
56- if not len (cache_control_values ):
57- del response ['Cache-Control' ]
58- else :
59- response ['Cache-Control' ] = ', ' .join (cache_control_values )
60-
61- return response
62-
63- def fix_IE_for_vary (request , response ):
64- """
65- This function will fix the bug reported at
66- http://support.microsoft.com/kb/824847/en-us?spid=8722&sid=global
67- by clearing the Vary header whenever the mime-type is not safe
68- enough for Internet Explorer to handle. Poor thing.
69- """
70- useragent = request .META .get ('HTTP_USER_AGENT' , '' ).upper ()
71- if 'MSIE' not in useragent and 'CHROMEFRAME' not in useragent :
72- return response
73-
74- # These mime-types that are decreed "Vary-safe" for IE:
75- safe_mime_types = ('text/html' , 'text/plain' , 'text/sgml' )
76-
77- # The first part of the Content-Type field will be the MIME type,
78- # everything after ';', such as character-set, can be ignored.
79- mime_type = response .get ('Content-Type' , '' ).partition (';' )[0 ]
80- if mime_type not in safe_mime_types :
81- try :
82- del response ['Vary' ]
83- except KeyError :
84- pass
85-
86- return response
87-
0 commit comments