ó
K~‰Pc           @   s.   d  Z  d „  Z d „  Z d „  Z d „  Z d S(   s@   
Functions that modify an HTTP request or response in some way.
c         C   s6   d | k r2 |  j  ƒ  r2 |  j | d ƒ | d <n  | S(   s  
    Ensures that we always use an absolute URI in any location header in the
    response. This is required by RFC 2616, section 14.30.

    Code constructing response objects is free to insert relative paths, as
    this function converts them to absolute paths.
    t   Location(   t   get_hostt   build_absolute_uri(   t   requestt   response(    (    s*   ../Django//lib/python/django/http/utils.pyt   fix_location_header   s    c         C   s   d | j  k o d k  n s. | j  d	 k rY | j rC g  | _ n	 d | _ d | d <n  |  j d k r‰ | j r} g  | _ q‰ d | _ n  | S(
   sŒ   
    Removes the content of responses for HEAD requests, 1xx, 204 and 304
    responses. Ensures compliance with RFC 2616, section 4.3.
    id   iÈ   iÌ   i0  t    t   0s   Content-Lengtht   HEAD(   iÌ   i0  (   t   status_codet	   streamingt   streaming_contentt   contentt   method(   R   R   (    (    s*   ../Django//lib/python/django/http/utils.pyt   conditional_content_removal   s    .			c         C   sñ   |  j  j d d ƒ j ƒ  } d | k r7 d | k r7 | Sd } | j d ƒ rí y | d =Wn t k
 rj n X| j d	 ƒ rí g  | d	 j d
 ƒ D]* } | j ƒ  j ƒ  | k rŽ | j ƒ  ^ qŽ } t | ƒ sÔ | d	 =qê d j	 | ƒ | d	 <qí n  | S(   sÚ   
    This function will prevent Django from serving a Content-Disposition header
    while expecting the browser to cache it (only when the browser is IE). This
    leads to IE not allowing the client to download.
    t   HTTP_USER_AGENTR   t   MSIEt   CHROMEFRAMEs   no-caches   no-stores   Content-Dispositiont   Pragmas   Cache-Controlt   ,s   , (   s   no-caches   no-store(
   t   METAt   gett   uppert
   has_headert   KeyErrort   splitt   stript   lowert   lent   join(   R   R   t	   useragentt   offending_headerst   valuet   cache_control_values(    (    s*   ../Django//lib/python/django/http/utils.pyt   fix_IE_for_attach,   s"    *
c         C   sŽ   |  j  j d d ƒ j ƒ  } d | k r7 d | k r7 | Sd } | j d d ƒ j d	 ƒ d
 } | | k rŠ y | d =WqŠ t k
 r† qŠ Xn  | S(   sö   
    This function will fix the bug reported at
    http://support.microsoft.com/kb/824847/en-us?spid=8722&sid=global
    by clearing the Vary header whenever the mime-type is not safe
    enough for Internet Explorer to handle.  Poor thing.
    R   R   R   R   s	   text/htmls
   text/plains	   text/sgmls   Content-Typet   ;i    t   Vary(   s	   text/htmls
   text/plains	   text/sgml(   R   R   R   t	   partitionR   (   R   R   R   t   safe_mime_typest	   mime_type(    (    s*   ../Django//lib/python/django/http/utils.pyt   fix_IE_for_varyI   s    N(   t   __doc__R   R   R"   R(   (    (    (    s*   ../Django//lib/python/django/http/utils.pyt   <module>   s   				