%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyo

�
a�Nc,@sdZddlZddlZddlZddlmZmZmZddlmZ	ddl
mZdddd	d
gZd
e
fd��YZed�Zed
�Zed�Zed�Zed�Zed�Zx<e�j�D]+\ZZeee�reje�nq�WiZd	efd��YZdefd��YZdefd��YZdefd��YZ e!d�Z"e#e#e#e#d�Z$e!d�Z%defd��YZ&defd��YZ'e'd d!d"�d#efd$��YZ(e(d%d&d'�d(efd)��YZ)e)d*d&d+�d,efd-��YZ*e*d.d&d/�d0e&fd1��YZ+e+d2d3d4�d5efd6��YZ,e,d7d3d8�d9efd:��YZ-e-d;d3d<�d=efd>��YZ.e.d?d@dA�dBefdC��YZ/e/dDd&dE�dFefdG��YZ0e0dHd3dI�x.dJd3dKdLdMfdNd3dKdLdOfdPd3dKdLdQfdRd@dKdSdEfdTd&dUdLdVfdWd3dUdLdXfdYd!dKdLdZfd[d&dUdLd\fd]d&dKdLd^fd_d&dKdSd`fdad&dKdSdbfdcd!dUdddefdfd@dKdSdgfdhd3dKdLdifdjd&dUdddkfdld3dUdSdmfdnd3dKdSdofdpd3dKdLdqfdrd3dKdLdsfdtd3dKdSdufdvd3dKdddwfdxd&dUdddyfdzd@dUdSd{fd|d3dKdSd}fd~d!dUdLdfd�d@dKdLd�fd�d3dKdSd�fd�d3dUdSd�fd�d@dKdSd�fd�d@dUdSd�fd�d@dUd�dXfd�d3dKdLd�fd�d!dKdLd�fd�d!dKdLd�fd�d!dKdLd�fd�d3dUdSd�fd�d@dKdLd�fd�d!dKdLd�fd�d!dKd�d�fd�d@dUd�d�ff(D]V\Z1Z2Z3Z4Z5iedL6e d�6e&dd6edS6e4Z6e5e6e1e2e5e3�_[6qWxIej7�D];Z8e8j1j9d�d��j:�Z;e8e<�e;<eje;�qsWeZ=xKe�j�D]:\ZZeee>�o�e?ee�re=je�nq�WdS(�s�
HTTP Message Header Fields (see RFC 4229)

This contains general support for HTTP/1.1 message headers [1]_ in a
manner that supports WSGI ``environ`` [2]_ and ``response_headers``
[3]_. Specifically, this module defines a ``HTTPHeader`` class whose
instances correspond to field-name items.  The actual field-content for
the message-header is stored in the appropriate WSGI collection (either
the ``environ`` for requests, or ``response_headers`` for responses).

Each ``HTTPHeader`` instance is a callable (defining ``__call__``)
that takes one of the following:

  - an ``environ`` dictionary, returning the corresponding header
    value by according to the WSGI's ``HTTP_`` prefix mechanism, e.g.,
    ``USER_AGENT(environ)`` returns ``environ.get('HTTP_USER_AGENT')``

  - a ``response_headers`` list, giving a comma-delimited string for
    each corresponding ``header_value`` tuple entries (see below).

  - a sequence of string ``*args`` that are comma-delimited into
    a single string value: ``CONTENT_TYPE("text/html","text/plain")``
    returns ``"text/html, text/plain"``

  - a set of ``**kwargs`` keyword arguments that are used to create
    a header value, in a manner dependent upon the particular header in
    question (to make value construction easier and error-free):
    ``CONTENT_DISPOSITION(max_age=CONTENT_DISPOSITION.ONEWEEK)``
    returns ``"public, max-age=60480"``

Each ``HTTPHeader`` instance also provides several methods to act on
a WSGI collection, for removing and setting header values.

  ``delete(collection)``

    This method removes all entries of the corresponding header from
    the given collection (``environ`` or ``response_headers``), e.g.,
    ``USER_AGENT.delete(environ)`` deletes the 'HTTP_USER_AGENT' entry
    from the ``environ``.

  ``update(collection, *args, **kwargs)``

    This method does an in-place replacement of the given header entry,
    for example: ``CONTENT_LENGTH(response_headers,len(body))``

    The first argument is a valid ``environ`` dictionary or
    ``response_headers`` list; remaining arguments are passed on to
    ``__call__(*args, **kwargs)`` for value construction.

  ``apply(collection, **kwargs)``

    This method is similar to update, only that it may affect other
    headers.  For example, according to recommendations in RFC 2616,
    certain Cache-Control configurations should also set the
    ``Expires`` header for HTTP/1.0 clients. By default, ``apply()``
    is simply ``update()`` but limited to keyword arguments.

This particular approach to managing headers within a WSGI collection
has several advantages:

  1. Typos in the header name are easily detected since they become a
     ``NameError`` when executed.  The approach of using header strings
     directly can be problematic; for example, the following should
     return ``None`` : ``environ.get("HTTP_ACCEPT_LANGUAGES")``

  2. For specific headers with validation, using ``__call__`` will
     result in an automatic header value check.  For example, the
     _ContentDisposition header will reject a value having ``maxage``
     or ``max_age`` (the appropriate parameter is ``max-age`` ).

  3. When appending/replacing headers, the field-name has the suggested
     RFC capitalization (e.g. ``Content-Type`` or ``ETag``) for
     user-agents that incorrectly use case-sensitive matches.

  4. Some headers (such as ``Content-Type``) are 0, that is,
     only one entry of this type may occur in a given set of
     ``response_headers``.  This module knows about those cases and
     enforces this cardinality constraint.

  5. The exact details of WSGI header management are abstracted so
     the programmer need not worry about operational differences
     between ``environ`` dictionary or ``response_headers`` list.

  6. Sorting of ``HTTPHeaders`` is done following the RFC suggestion
     that general-headers come first, followed by request and response
     headers, and finishing with entity-headers.

  7. Special care is given to exceptional cases such as Set-Cookie
     which violates the RFC's recommendation about combining header
     content into a single entry using comma separation.

A particular difficulty with HTTP message headers is a categorization
of sorts as described in section 4.2:

    Multiple message-header fields with the same field-name MAY be
    present in a message if and only if the entire field-value for
    that header field is defined as a comma-separated list [i.e.,
    #(values)]. It MUST be possible to combine the multiple header
    fields into one "field-name: field-value" pair, without changing
    the semantics of the message, by appending each subsequent
    field-value to the first, each separated by a comma.

This creates three fundamentally different kinds of headers:

  - Those that do not have a #(values) production, and hence are
    singular and may only occur once in a set of response fields;
    this case is handled by the ``_SingleValueHeader`` subclass.

  - Those which have the #(values) production and follow the
    combining rule outlined above; our ``_MultiValueHeader`` case.

  - Those which are multi-valued, but cannot be combined (such as the
    ``Set-Cookie`` header due to its ``Expires`` parameter); or where
    combining them into a single header entry would cause common
    user-agents to fail (``WWW-Authenticate``, ``Warning``) since
    they fail to handle dates even when properly quoted. This case
    is handled by ``_MultiEntryHeader``.

Since this project does not have time to provide rigorous support
and validation for all headers, it does a basic construction of
headers listed in RFC 2616 (plus a few others) so that they can
be obtained by simply doing ``from paste.httpheaders import *``;
the name of the header instance is the "common name" less any
dashes to give CamelCase style names.

.. [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
.. [2] http://www.python.org/peps/pep-0333.html#environ-variables
.. [3] http://www.python.org/peps/pep-0333.html#the-start-response-callable

i����N(t
formatdatetparsedate_tzt	mktime_tz(ttime(tHTTPBadRequestt
get_headertlist_headerstnormalize_headerst
HTTPHeadertEnvironVariablecBs)eZdZd�Zd�Zd�ZRS(s�
    a CGI ``environ`` variable as described by WSGI

    This is a helper object so that standard WSGI ``environ`` variables
    can be extracted w/o syntax error possibility.
    cCs|j|d�S(Nt(tget(tselftenviron((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt__call__�scCsd|S(Ns<EnvironVariable %s>((R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt__repr__�scCs|||<dS(N((RR
tvalue((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytupdate�s(t__name__t
__module__t__doc__RRR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR	�s		tREMOTE_USERtREMOTE_SESSIONt	AUTH_TYPEtREQUEST_METHODtSCRIPT_NAMEt	PATH_INFOcBs�eZdZdZdZdZiZd�Zd�Zd�Z	dddd�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�ZRS(s
    an HTTP header

    HTTPHeader instances represent a particular ``field-name`` of an
    HTTP message header. They do not hold a field-value, but instead
    provide operations that work on is corresponding values.  Storage
    of the actual field values is done with WSGI ``environ`` or
    ``response_headers`` as appropriate.  Typically, a sub-classes that
    represent a specific HTTP header, such as _ContentDisposition, are
    0.  Once constructed the HTTPHeader instances themselves
    are immutable and stateless.

    For purposes of documentation a "container" refers to either a
    WSGI ``environ`` dictionary, or a ``response_headers`` list.

    Member variables (and correspondingly constructor arguments).

      ``name``

          the ``field-name`` of the header, in "common form"
          as presented in RFC 2616; e.g. 'Content-Type'

      ``category``

          one of 'general', 'request', 'response', or 'entity'

      ``version``

          version of HTTP (informational) with which the header should
          be recognized

      ``sort_order``

          sorting order to be applied before sorting on
          field-name when ordering headers in a response

    Special Methods:

       ``__call__``

           The primary method of the HTTPHeader instance is to make
           it a callable, it takes either a collection, a string value,
           or keyword arguments and attempts to find/construct a valid
           field-value

       ``__lt__``

           This method is used so that HTTPHeader objects can be
           sorted in a manner suggested by RFC 2616.

       ``__str__``

           The string-value for instances of this class is
           the ``field-name``.

    Primary Methods:

       ``delete()``

           remove the all occurrences (if any) of the given
           header in the collection provided

       ``update()``

           replaces (if they exist) all field-value items
           in the given collection with the value provided

       ``tuples()``

           returns a set of (field-name, field-value) tuples
           5 for extending ``response_headers``

    Custom Methods (these may not be implemented):

       ``apply()``

           similar to ``update``, but with two differences; first,
           only keyword arguments can be used, and second, specific
           sub-classes may introduce side-effects

       ``parse()``

           converts a string value of the header into a more usable
           form, such as time in seconds for a date header, etc.

    The collected versions of initialized header instances are immediately
    registered and accessible through the ``get_header`` function.  Do not
    inherit from this directly, use one of ``_SingleValueHeader``,
    ``_MultiValueHeader``, or ``_MultiEntryHeader`` as appropriate.
    s1.1tgeneralR
cKs
t��dS(s�
        build header value from keyword arguments

        This method is used to build the corresponding header value when
        keyword arguments (or no arguments) were provided.  The result
        should be a sequence of values.  For example, the ``Expires``
        header takes a keyword argument ``time`` (e.g. time.time()) from
        which it returns a the corresponding date.
        N(tNotImplementedError(Rtkwargs((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytcomposes
cOs
t��dS(s[
        convert raw header value into more usable form

        This method invokes ``values()`` with the arguments provided,
        parses the header results, and then returns a header-specific
        data structure corresponding to the header.  For example, the
        ``Expires`` header returns seconds (as returned by time.time())
        N(R(RtargsR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytparses	cKs|j||�dS(s�
        update the collection /w header value (may have side effects)

        This method is similar to ``update`` only that usage may result
        in other headers being changed as recommended by the corresponding
        specification.  The return value is defined by the particular
        sub-class. For example, the ``_CacheControl.apply()`` sets the
        ``Expires`` header in addition to its normal behavior.
        N(R(Rt
collectionR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytapply(s
c
Cs�t|dt�}|r|Stj|�}||_|p@|j|_|pR|j|_|pd|j|_|t|jj	�<idd6dd6dd6dd	6|j|_
t|d
d|jj�j
dd
��|_t|d|jj	��|_|S(s�
        construct a new ``HTTPHeader`` instance

        We use the ``__new__`` operator to ensure that only one
        ``HTTPHeader`` instance exists for each field-name, and to
        register the header so that it can be found/enumerated.
        t
raiseErroriRitrequestitresponseitentityt
_environ_nametHTTP_t-t_t
_headers_name(RtFalsetobjectt__new__tnametcategorytversiont	referencet_headerstlowert
sort_ordertgetattrtuppertreplaceR'R+(tclsR/R0R2R1R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR.7s 			%	cCs|jS(N(R/(R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt__str__[scCsEt|t�rA|j|jkr1|j|jkS|j|jkStS(s
        sort header instances as specified by RFC 2616

        Re-define sorting so that general headers are first, followed
        by request/response headers, and then entity headers.  The
        list.sort() methods use the less-than operator for this purpose.
        (t
isinstanceRR5R/R,(Rtother((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt__lt__^s
cCs6|jrd|jpd}d|jj|j|fS(Ns (%s)R
s	<%s %s%s>(R2t	__class__RR/(Rtref((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRlscOs�|s|j|�Stt|d�kr�g}|jj�}xJg|dD]$\}}|j�|krL|^qLD]}|j|�qtW|Stt|d�kr�|dj|j�}|s�dS|fSx|D]}q�W|S(sq
        find/construct field-value(s) for the given header

        Resolution is done according to the following arguments:

        - If only keyword arguments are given, then this is equivalent
          to ``compose(**kwargs)``.

        - If the first (and only) argument is a dict, it is assumed
          to be a WSGI ``environ`` and the result of the corresponding
          ``HTTP_`` entry is returned.

        - If the first (and only) argument is a list, it is assumed
          to be a WSGI ``response_headers`` and the field-value(s)
          for this header are collected and returned.

        - In all other cases, the arguments are collected, checked that
          they are string values, possibly verified by the header's
          logic, and returned.

        At this time it is an error to provide keyword arguments if args
        is present (this might change).  It is an error to provide both
        a WSGI object and also string arguments.  If no arguments are
        provided, then ``compose()`` is called to provide a default
        value for the header; if there is not default it is an error.
        i((	RtlistttypeR/R4tappendtdictRR'(RRRtresultR/theaderRtitem((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytvaluesps"
"
cOs0|j||�}|sdSt|d�j�S(s�
        converts ``values()`` into a string value

        This method converts the results of ``values()`` into a string
        value for common usage.  By default, it is asserted that only
        one value exists; if you need to access all values then either
        call ``values()`` directly, or inherit ``_MultiValueHeader``
        which overrides this method to return a comma separated list of
        values as described by section 4.2 of RFC 2616.
        R
i(RGtstrtstrip(RRRRG((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�scCs�t|�tkr2|j|kr.||j=n|Sd}xJ|t|�kr�||dj�|jkrw||=q;n|d7}q;WdS(sS
        removes all occurances of the header from the collection provided
        iiN(RARCR'tlenR4R+(RR!ti((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytdelete�s
cOs�|j||�}|s)|j|�dSt|�tkrL|||j<dSd}t}xl|t|�kr�||dj�|jkr�|r�||=q[n|j	|f||<t
}n|d7}q[W|s�|j|j	|f�ndS(s�
        updates the collection with the provided header value

        This method replaces (in-place when possible) all occurrences of
        the given header with the provided value.  If no value is
        provided, this is the same as ``remove`` (note that this case
        can only occur if the target is a collection w/o a corresponding
        header value). The return value is the new header value (which
        could be a list for ``_MultiEntryHeader`` instances).
        Nii(RRLRARCR'R,RJR4R+R/tTrueRB(RR!RRRRKtfound((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�s&

	cOs,|j||�}|sdS|j|fgS(N((RR/(RRRR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyttuples�sN(RRRR1R0R2t
extensionsRR R"tNoneR.R:R=RRGRRLRRO(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�s"Z			$				/			 t_SingleValueHeadercBseZdZRS(s�
    a ``HTTPHeader`` with exactly a single value

    This is the default behavior of ``HTTPHeader`` where returning a
    the string-value of headers via ``__call__`` assumes that only
    a single value exists.
    (RRR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRR�st_MultiValueHeadercBs eZdZd�Zd�ZRS(s�
    a ``HTTPHeader`` with one or more values

    The field-value for these header instances is is allowed to be more
    than one value; whereby the ``__call__`` method returns a comma
    separated list as described by section 4.2 of RFC 2616.
    cOsH|j||�}|sdSdjg|D]}t|�j�^q)�S(NR
s, (RGtjoinRHRI(RRRtresultstv((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�scOsJ|j||�}|jd�}g|D]}|j�r(|j�^q(S(Nt,(RtsplitRI(RRRRRGRV((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR s
(RRRRR (((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRS�s	t_MultiEntryHeadercBs eZdZd�Zd�ZRS(sa
    a multi-value ``HTTPHeader`` where items cannot be combined with a comma

    This header is multi-valued, but the values should not be combined
    with a comma since the header is not in compliance with RFC 2616
    (Set-Cookie due to Expires parameter) or which common user-agents do
    not behave well when the header values are combined.
    cOs*|j|�|j|j||��dS(N(RLtextendRO(RR!RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRs
cOsB|j||�}|sdSg|D]}|j|j�f^q#S(N((RGR/RI(RRRRGR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyROs(RRRRRO(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRYs	cCsQtjt|�j�j�jdd��}|rM|rMtd|��n|S(s�
    find the given ``HTTPHeader`` instance

    This function finds the corresponding ``HTTPHeader`` for the
    ``name`` provided.  So that python-style names can be used,
    underscores are converted to dashes before the lookup.
    R*R)s'%s' is an unknown header(R3RRHRIR4R8tAssertionError(R/R#tretval((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRs-
cCs�|p|p|p|s-t}}}}ng}xN|df|df|df|dffD]"\}}|r^|j|�q^q^Wgtj�D]}|j|kr�|^q�S(s' list all headers for a given category RR$R%R&(RMRBR3RGR0(RR$R%R&tsearchtbooltstrvalthead((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR)s"c	s�i�x�tt|��D]�}||\}}t||�}|s�djg|jdd�jd�D]}|j�^qf�}||f||<d�|<qnt|�|f||<|j�t|�<qW�fd�}|j	|�dS(s
    sort headers as suggested by  RFC 2616

    This alters the underlying response_headers to use the common
    name for each header; as well as sorting them with general
    headers first, followed by request/response headers, then
    entity headers, and unknown headers last.
    R)R*icsJ�|d}�|d}||kr=t|d|d�St||�S(Ni(tcmp(tatbtactbc(R0(sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytcompareIs
N(
trangeRJRRTR8RXt
capitalizeRHR5tsort(	tresponse_headerststricttidxtkeytvalR`txtnewheadRf((R0sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR4s		4
t_DateHeadercBs&eZdZddd�Zd�ZRS(sv
    handle date-based headers

    This extends the ``_SingleValueHeader`` object with specific
    treatment of time values:

    - It overrides ``compose`` to provide a sole keyword argument
      ``time`` which is an offset in seconds from the current time.

    - A ``time`` method is provided which parses the given value
      and returns the current time value.
    cCs/|pt�}|r"||7}nt|�fS(N(tnowR(RRtdelta((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR_s
cOsf|j||�}|rbytt|��SWqbttfk
r^td|j|f��qbXndS(s/ return the time value (in seconds since 1970) s-Received an ill-formed timestamp for %s: %s
N(RRRt	TypeErrort
OverflowErrorRR/(RRRR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR fsN(RRRRQRR (((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRqQst
_CacheControlcBsleZdZd	ZedZedZedZedZd
d
d
e	d
d
e	d�Z
d�Zd�ZRS(s/

    Cache-Control, RFC 2616 14.9  (use ``CACHE_CONTROL``)

    This header can be constructed (using keyword arguments), by
    first specifying one of the following mechanisms:

      ``public``

          if True, this argument specifies that the
          response, as a whole, may be cashed.

      ``private``

          if True, this argument specifies that the response, as a
          whole, may be cashed; this implementation does not support
          the enumeration of private fields

      ``no_cache``

          if True, this argument specifies that the response, as a
          whole, may not be cashed; this implementation does not
          support the enumeration of private fields

    In general, only one of the above three may be True, the other 2
    must then be False or None.  If all three are None, then the cache
    is assumed to be ``public``.  Following one of these mechanism
    specifiers are various modifiers:

      ``no_store``

          indicates if content may be stored on disk;
          otherwise cache is limited to memory (note:
          users can still save the data, this applies
          to intermediate caches)

      ``max_age``

          the maximum duration (in seconds) for which
          the content should be cached; if ``no-cache``
          is specified, this defaults to 0 seconds

      ``s_maxage``

          the maximum duration (in seconds) for which the
          content should be allowed in a shared cache.

      ``no_transform``

          specifies that an intermediate cache should
          not convert the content from one type to
          another (e.g. transform a BMP to a PNG).

      ``extensions``

          gives additional cache-control extensions,
          such as items like, community="UCI" (14.9.6)

    The usage of ``apply()`` on this header has side-effects. As
    recommended by RFC 2616, if ``max_age`` is provided, then then the
    ``Expires`` header is also calculated for HTTP/1.0 clients and
    proxies (this is done at the time ``apply()`` is called).  For
    ``no-cache`` and for ``private`` cases, we either do not want the
    response cached or do not want any response accidently returned to
    other users; so to prevent this case, we set the ``Expires`` header
    to the time of the request, signifying to HTTP/1.0 transports that
    the content isn't to be cached.  If you are using SSL, your
    communication is already "private", so to work with HTTP/1.0
    browsers over SSL, consider specifying your cache as ``public`` as
    the distinction between public and private is moot.
    i<iiii4c
Ks/d}	g}
|tkr(|
jd�n/|tkrD|
jd�n|}	|
jd�|rm|
jd�n|r�|
jd�n|dk	r�|
jd|�n|dk	r�|
jd|�nx_|j�D]Q\}}||jkr�td	|��n|
jd
|jdd�|f�q�W|
|	fS(
Nitprivatesno-cachetpublicsno-storesno-transforms
max-age=%dss-maxage=%dsunexpected extension used: '%s's%s="%s"R*R)(RMRBRQtitemsRPR[R8(
RRxRwtno_cachetno_storetmax_agets_maxagetno_transformRPtexpiresRDtkRV((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt_compose�s*
'cKs|j|�\}}|S(N(R�(RRRDR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�scKsK|j|�\}}|dk	r7tj|d|�n|j||�|S(s* returns the offset expiration in seconds RsN(R�RQtEXPIRESR(RR!RRDR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR"�s
iN(
RRRtONE_HOURtONE_DAYtONE_WEEKt	ONE_MONTHtONE_YEARRQR,R�RR"(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRvwsF



			s
Cache-ControlRsRFC 2616, 14.9t_ContentTypecBsDeZdZdZdZdZdZdZdZdddd�Z
RS(	sg
    Content-Type, RFC 2616 section 14.17

    Unlike other headers, use the CGI variable instead.
    s1.0tCONTENT_TYPEsapplication/octet-streams
text/plains	text/htmlstext/xmlcCse|s(|dkrd}q(|jfSn|s7d}nd||f}|r^|d|7}n|fS(	Ntplainthtmltxmlttextt*s%s/%ss; charset=%s(R�R�R�(tUNKNOWN(RtmajortminortcharsetRD((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRs	
	N(RRRR1R'R�t
TEXT_PLAINt	TEXT_HTMLtTEXT_XMLRQR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��ssContent-TypeR&sRFC 2616, 14.17t_ContentLengthcBseZdZdZdZRS(si
    Content-Length, RFC 2616 section 14.13

    Unlike other headers, use the CGI variable instead.
    s1.0tCONTENT_LENGTH(RRRR1R'(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�ssContent-LengthsRFC 2616, 14.13t_ContentDispositioncBs2eZdZdddd�Zd�Zd�ZRS(s�
    Content-Disposition, RFC 2183 (use ``CONTENT_DISPOSITION``)

    This header can be constructed (using keyword arguments),
    by first specifying one of the following mechanisms:

      ``attachment``

          if True, this specifies that the content should not be
          shown in the browser and should be handled externally,
          even if the browser could render the content

      ``inline``

         exclusive with attachment; indicates that the content
         should be rendered in the browser if possible, but
         otherwise it should be handled externally

    Only one of the above 2 may be True.  If both are None, then
    the disposition is assumed to be an ``attachment``. These are
    distinct fields since support for field enumeration may be
    added in the future.

      ``filename``

          the filename parameter, if any, to be reported; if
          this is None, then the current object's filename
          attribute is used

    The usage of ``apply()`` on this header has side-effects. If
    filename is provided, and Content-Type is not set or is
    'application/octet-stream', then the mimetypes.guess is used to
    upgrade the Content-Type setting.
    cCs�g}|tkr"|jd�n
|jd�|ro|jd�d}|jd�d}|jd|�ndj|�f|fS(Ntinlinet
attachmentt/i����s\s
filename="%s"s; (RMRBRXRT(RR�R�tfilenameRD((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�Bs
cKs|j|�\}}|S(N(R�(RRRDtmimetype((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRQscKs�|j|�\}}t|�}|r}|s=tj|kr}tj|�\}}|r}tj|kr}tj||�q}n|j||�|S(s/ return the new Content-Type side-effect value (R�R�R�t	mimetypest
guess_typeR(RR!RRDR�R�R*((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR"UsN(RRRRQR�RR"(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�s"	sContent-DispositionsRFC 2183t_IfModifiedSincecBs&eZdZdZd�Zd�ZRS(s3
    If-Modified-Since, RFC 2616 section 14.25
    s1.0cOs#tj|||�jdd�dS(s�
        Split the value on ';' incase the header includes extra attributes. E.g.
        IE 6 is known to send:
        If-Modified-Since: Sun, 25 Jun 2006 20:36:35 GMT; length=1506
        t;ii(RqRRX(RRR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyRhscOsDtj|||�}|r@|t�kr@td|j��n|S(NsrPlease check your system clock.
According to this server, the time provided in the
%s header is in the future.
(RqR RrRR/(RRRR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR ps(RRRR1RR (((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�bs	sIf-Modified-SinceR$sRFC 2616, 14.25t_RangecBseZdZd�ZRS(sc
    Range, RFC 2616 14.35 (use ``RANGE``)

    According to section 14.16, the response to this message should be a
    206 Partial Content and that if multiple non-overlapping byte ranges
    are requested (it is an error to request multiple overlapping
    ranges) the result should be sent as multipart/byteranges mimetype.

    The server should respond with '416 Requested Range Not Satisfiable'
    if the requested ranges are out-of-bounds.  The specification also
    indicates that a syntax error in the Range request should result in
    the header being ignored rather than a '400 Bad Request'.
    cOs|j||�}|sdSg}d}y�|jdd�\}}|j�j�}x�|jd�D]�}|jd�\}	}
|	j�s�d}	nt|	�}	|	|kr�t��n|
j�s�d}
nt|
�}
|
}|j|	|
f�qeWWntk
rdSX||fS(s�
        Returns a tuple (units, list), where list is a sequence of
        (begin, end) tuples; and end is None if it was not provided.
        i����t=iRWR)iN(RRQRXRIR4tintt
ValueErrorRB(RRRRtrangestlast_endtunitsRgRFtbegintend((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR �s.		
(RRRR (((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�zs
tRangesRFC 2616, 14.35t_AcceptLanguagecBseZdZd�ZRS(s0
    Accept-Language, RFC 2616 section 14.4
    cOsH|j||�}|dkr"gSg|jd�D]}|r2|^q2}g}x�|D]�}|jd�}|dj�j�|d}}	d}
xn|	D]f}d|kr�q�n|jd�\}}
|j�j�}|
j�}
|dkr�t|
�}
q�q�W|j||
f�qWW|jd��g|D]\}}
|^q2S(	s�
        Return a list of language tags sorted by their "q" values.  For example,
        "en-us,en;q=0.5" should return ``["en-us", "en"]``.  If there is no
        ``Accept-Language`` header present, default to ``[]``.
        RWR�iiR�tqcSst|d|d�S(Ni(Ra(RbRc((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt<lambda>�sN(RRQRXRIR4tfloatRBRi(RRRRERVtlangstqstlangtpiecestparamsR�tparamtlvaluetrvalue((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR �s((
!
(RRRR (((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��ssAccept-LanguagesRFC 2616, 14.4t
_AcceptRangescBseZdZddd�ZRS(s.
    Accept-Ranges, RFC 2616 section 14.5
    cCs|r
dSdS(Ntbytestnone(sbytes(snone((RR�R�((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�sN(RRRRQR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��ss
Accept-RangesR%sRFC 2616, 14.5t
_ContentRangecBs eZdZdddd�ZRS(s.
    Content-Range, RFC 2616 section 14.6
    cCsd|||f}|fS(Nsbytes %d-%d/%d((Rt
first_bytet	last_bytettotal_lengthR\((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�sN(RRRRQR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��ss
Content-RangesRFC 2616, 14.6t_AuthorizationcBs,eZdZdddddddd�ZRS(s2
    Authorization, RFC 2617 (RFC 2616, 14.8)
    cs
|s
|r@d|j�|j�f}d|jd�j�S�pId�|jd�\}	}
|
jdd�\}
}	tj�}|j|
�||�|jdd�\}}tjtj|��}
d	tf��fd
��Y}d|j	|�|
�}|fS(Ns%s:%ssBasic %stbase64R�srealm="t"it tFakeRequestcs5eZ�fd�Zd�Z�fd�ZeZRS(cs�S(N((R(tpath(sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pytget_full_url�scSstS(N(R,(R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pythas_data�scs
�p	dS(NtGET((R(tmethod(sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt
get_method�s(RRR�R�R�tget_selector((R�R�(sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��s	s	Digest %s(
RItencodeRXturllib2tAbstractDigestAuthHandlertadd_passwordtparse_keqv_listtparse_http_listR-tget_authorization(Rtdigesttbasictusernametpasswordt	challengeR�R�tuserpassR*trealmtauthttokentchalR�R\((R�R�sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR�s
N(RRRRQR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyR��st
AuthorizationsRFC 2617tAccepts1.1smulti-valuesRFC 2616, 14.1sAccept-CharsetsRFC 2616, 14.2sAccept-EncodingsRFC 2616, 14.3tAgetsingulartAllows1.0sRFC 2616, 14.7tCookiesRFC 2109/Netscapet
ConnectionsRFC 2616, 14.10sContent-EncodingsRFC 2616, 14.11sContent-LanguagesRFC 2616, 14.12sContent-LocationsRFC 2616, 14.14sContent-MD5sRFC 2616, 14.15tDatesdate-headersRFC 2616, 14.18tETagsRFC 2616, 14.19tExpectsRFC 2616, 14.20tExpiressRFC 2616, 14.21tFromsRFC 2616, 14.22tHostsRFC 2616, 14.23sIf-MatchsRFC 2616, 14.24s
If-None-MatchsRFC 2616, 14.26sIf-RangesRFC 2616, 14.27sIf-Unmodified-SincesRFC 2616, 14.28s
Last-ModifiedsRFC 2616, 14.29tLocationsRFC 2616, 14.30sMax-ForwardssRFC 2616, 14.31tPragmasRFC 2616, 14.32sProxy-AuthenticatesRFC 2616, 14.33sProxy-AuthorizationsRFC 2616, 14.34tReferersRFC 2616, 14.36sRetry-AftersRFC 2616, 14.37tServersRFC 2616, 14.38s
Set-Cookiesmulti-entrytTEsRFC 2616, 14.39tTrailersRFC 2616, 14.40sTransfer-EncodingsRFC 2616, 14.41tUpgradesRFC 2616, 14.42s
User-AgentsRFC 2616, 14.43tVarysRFC 2616, 14.44tViasRFC 2616, 14.45tWarningsRFC 2616, 14.46sWWW-AuthenticatesRFC 2616, 14.47R)R*(@RR�R�tretrfc822RRRRRrthttpexceptionsRt__all__RHR	RRRRRRtglobalsRyt_namet_objR;RBR3R-RRRRSRYRMRRQRRRqRvR�R�R�R�R�R�R�R�R�R/R0R1tstyletcommenttklassRGR`R8R7theadnametlocalst
__pudge_all__RAt
issubclass(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/httpheaders.pyt<module>�s�	
�;

&{	B0 	+



Zerion Mini Shell 1.0