σ
³Ebc           @   sp  d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l m
 Z
 d  d l m Z d  d	 l m Z d  d
 l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d e f d     YZ d e f d     YZ d S(   i   (   t   string_types(   t   _get_environ(   t   ContentRange(   t   RequestCacheControl(   t   ResponseCacheControl(   t   generate_etag(   t	   http_date(   t   is_resource_modified(   t   parse_cache_control_header(   t   parse_content_range_header(   t
   parse_date(   t   parse_etags(   t   parse_if_range_header(   t   parse_range_header(   t
   quote_etag(   t   unquote_etag(   t   cached_property(   t   header_property(   t   _clean_accept_ranges(   t   _RangeWrappert   ETagRequestMixinc           B   sw   e  Z d  Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z	 e d    Z
 RS(   sΰ   Add entity tag and cache descriptors to a request object or object with
    a WSGI environment available as :attr:`~BaseRequest.environ`.  This not
    only provides access to etags but also to the cache control header.
    c         C   s"   |  j  j d  } t | d t  S(   sw   A :class:`~werkzeug.datastructures.RequestCacheControl` object
        for the incoming cache control headers.
        t   HTTP_CACHE_CONTROLN(   t   environt   getR   t   NoneR   (   t   selft   cache_control(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR      s    c         C   s   t  |  j j d   S(   s~   An object containing all the etags in the `If-Match` header.

        :rtype: :class:`~werkzeug.datastructures.ETags`
        t   HTTP_IF_MATCH(   R   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   if_match%   s    c         C   s   t  |  j j d   S(   s   An object containing all the etags in the `If-None-Match` header.

        :rtype: :class:`~werkzeug.datastructures.ETags`
        t   HTTP_IF_NONE_MATCH(   R   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   if_none_match-   s    c         C   s   t  |  j j d   S(   s9   The parsed `If-Modified-Since` header as datetime object.t   HTTP_IF_MODIFIED_SINCE(   R
   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   if_modified_since5   s    c         C   s   t  |  j j d   S(   s;   The parsed `If-Unmodified-Since` header as datetime object.t   HTTP_IF_UNMODIFIED_SINCE(   R
   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   if_unmodified_since:   s    c         C   s   t  |  j j d   S(   s   The parsed `If-Range` header.

        .. versionadded:: 0.7

        :rtype: :class:`~werkzeug.datastructures.IfRange`
        t   HTTP_IF_RANGE(   R   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   if_range?   s    c         C   s   t  |  j j d   S(   s{   The parsed `Range` header.

        .. versionadded:: 0.7

        :rtype: :class:`~werkzeug.datastructures.Range`
        t
   HTTP_RANGE(   R   R   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   rangeI   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R    R"   R$   R&   (    (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR      s   
t   ETagResponseMixinc           B   s°   e  Z d  Z e d    Z d   Z d   Z d d d  Z e	 d d  Z
 e	 e	 d  Z e	 d  Z d   Z e	 d	  Z e d
 d d Z e d    Z e j d    Z RS(   s΄  Adds extra functionality to a response object for etag and cache
    handling.  This mixin requires an object with at least a `headers`
    object that implements a dict like interface similar to
    :class:`~werkzeug.datastructures.Headers`.

    If you want the :meth:`freeze` method to automatically add an etag, you
    have to mixin this method before the response base class.  The default
    response class does not do that.
    c            s+     f d   } t    j j d  | t  S(   s­   The Cache-Control general-header field is used to specify
        directives that MUST be obeyed by all caching mechanisms along the
        request/response chain.
        c            sC   |  r# d   j  k r#   j  d =n |  r? |  j     j  d <n  d  S(   Ns   cache-controls   Cache-Control(   t   headerst	   to_header(   R   (   R   (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt	   on_updatef   s    s   cache-control(   R   R+   R   R   (   R   R-   (    (   R   sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR   _   s    c         C   s.   |  j  d k r* t |  j | |  |  _ n  d S(   s8   Wrap existing Response in case of Range Request context.iΞ   N(   t   status_codeR   t   response(   R   t   startt   length(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   _wrap_responsep   s    c         C   sJ   d | k s@ t  | |  j j d  d |  j j d  d t oI d | k S(   s   Return ``True`` if `Range` header is present and if underlying
        resource is considered unchanged when compared with `If-Range` header.
        R#   t   etags   last-modifiedt   ignore_if_rangeR%   N(   R   R+   R   R   t   False(   R   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   _is_range_request_processableu   s    
c   	      C   s  d d l  m } | d	 k s8 | d	 k s8 |  j |  r< t St | j d   } | d	 k rl | |   n  | j |  } | j |  } | d	 k s’ | d	 k r± | |   n  | d | d } | |  j	 d <| |  j	 d <| |  _
 d |  _ |  j | d |  t S(
   sΫ  Handle Range Request related headers (RFC7233).  If `Accept-Ranges`
        header is valid, and Range Request is processable, we set the headers
        as described by the RFC, and wrap the underlying response in a
        RangeWrapper.

        Returns ``True`` if Range Request can be fulfilled, ``False`` otherwise.

        :raises: :class:`~werkzeug.exceptions.RequestedRangeNotSatisfiable`
                 if `Range` header could not be parsed or satisfied.
        i   (   t   RequestedRangeNotSatisfiableR%   i   i    s   Content-Lengths   Accept-RangesiΞ   N(   t
   exceptionsR7   R   R6   R5   R   R   t   range_for_lengtht   to_content_range_headerR+   t   content_rangeR.   R2   t   True(	   R   R   t   complete_lengtht   accept_rangesR7   t   parsed_ranget   range_tuplet   content_range_headert   content_length(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   _process_range_request   s&    		c         C   s  t  |  } | d d k rd |  j k r> t   |  j d <n  t |  } |  j | | |  } | rΑ t | |  j j d  d |  j j d   rΑ t | j d   r΅ d	 |  _	 qΑ d
 |  _	 n  |  j
 rd |  j k r|  j   } | d k	 r| |  j d <qqn  |  S(   s  Make the response conditional to the request.  This method works
        best if an etag was defined for the response already.  The `add_etag`
        method can be used to do that.  If called without etag just the date
        header is set.

        This does nothing if the request method in the request or environ is
        anything but GET or HEAD.

        For optimal performance when handling range requests, it's recommended
        that your response data object implements `seekable`, `seek` and `tell`
        methods as described by :py:class:`io.IOBase`.  Objects returned by
        :meth:`~werkzeug.wsgi.wrap_file` automatically implement those methods.

        It does not remove the body of the response because that's something
        the :meth:`__call__` function does for us automatically.

        Returns self so that you can do ``return resp.make_conditional(req)``
        but modifies the object in-place.

        :param request_or_environ: a request object or WSGI environment to be
                                   used to make the response conditional
                                   against.
        :param accept_ranges: This parameter dictates the value of
                              `Accept-Ranges` header. If ``False`` (default),
                              the header is not set. If ``True``, it will be set
                              to ``"bytes"``. If ``None``, it will be set to
                              ``"none"``. If it's a string, it will use this
                              value.
        :param complete_length: Will be used only in valid Range Requests.
                                It will set `Content-Range` complete length
                                value and compute `Content-Length` real value.
                                This parameter is mandatory for successful
                                Range Requests completion.
        :raises: :class:`~werkzeug.exceptions.RequestedRangeNotSatisfiable`
                 if `Range` header could not be parsed or satisfied.
        t   REQUEST_METHODt   GETt   HEADt   datet   DateR3   s   last-modifiedR   i  i0  s   content-lengths   Content-Length(   RE   RF   N(   R   R+   R   R   RC   R   R   R   R   R.   t    automatically_set_content_lengtht   calculate_content_length(   R   t   request_or_environR>   R=   R   t   is206R1   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   make_conditional«   s(    '
	c         C   s8   | s d |  j  k r4 |  j t |  j    |  n  d S(   s:   Add an etag for the current response if there is none yet.R3   N(   R+   t   set_etagR   t   get_data(   R   t	   overwritet   weak(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   add_etagο   s    c         C   s   t  | |  |  j d <d S(   s8   Set the etag, and override the old one if there was one.t   ETagN(   R   R+   (   R   R3   RQ   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyRN   τ   s    c         C   s   t  |  j j d   S(   s{   Return a tuple in the form ``(etag, is_weak)``.  If there is no
        ETag the return value is ``(None, None)``.
        RS   (   R   R+   R   (   R   (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   get_etagψ   s    c         C   s*   | s |  j    n  t t |   j   d S(   sΠ   Call this method if you want to make your response object ready for
        pickeling.  This buffers the generator if there is one.  This also
        sets the etag unless `no_etag` is set to `True`.
        N(   RR   t   superR*   t   freeze(   R   t   no_etag(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyRV   ώ   s    s   Accept-Rangest   docsο   The `Accept-Ranges` header. Even though the name would
        indicate that multiple values are supported, it must be one
        string token only.

        The values ``'bytes'`` and ``'none'`` are common.

        .. versionadded:: 0.7c            sU     f d   } t    j j d  |  } | d k rQ t d d d d | } n  | S(   sΉ   The ``Content-Range`` header as a
        :class:`~werkzeug.datastructures.ContentRange` object. Available
        even if the header is not set.

        .. versionadded:: 0.7
        c            s*   |  s   j  d =n |  j     j  d <d  S(   Ns   content-ranges   Content-Range(   R+   R,   (   t   rng(   R   (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR-     s    s   content-rangeR-   N(   R	   R+   R   R   R   (   R   R-   t   rv(    (   R   sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR;     s
    	c         C   sI   | s |  j  d =n2 t | t  r2 | |  j  d <n | j   |  j  d <d  S(   Ns   content-ranges   Content-Range(   R+   t
   isinstanceR    R,   (   R   t   value(    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR;   )  s
    N(   R'   R(   R)   t   propertyR   R2   R6   R   RC   R5   RM   RR   RN   RT   RV   R   R>   R;   t   setter(    (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyR*   T   s   			(C			N(   t   _compatR    t	   _internalR   t   datastructuresR   R   R   t   httpR   R   R   R   R	   R
   R   R   R   R   R   t   utilsR   R   t   wrappers.base_responseR   t   wsgiR   t   objectR   R*   (    (    (    sn   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/wrappers/etag.pyt   <module>   s*   =