ó
Ñ7ec           @  sË  d  d l  m Z d  d l Z d  d l Z d  d l 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 m Z m Z d  d l m Z d  d	 l m Z m Z d  d
 l m Z d  d l m Z m Z d  d l m Z m Z m Z m Z m  Z  d  d l! m" Z" m# Z# d  d l$ m% Z% m& Z& m' Z' m( Z( e) ƒ  Z* e j+ d ƒ Z, d e- f d „  ƒ  YZ. d e/ f d „  ƒ  YZ0 d e) f d „  ƒ  YZ1 d e f d „  ƒ  YZ2 d „  Z3 d „  Z4 d „  Z5 d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   BytesIO(   t   chain(   t   settings(   t   signing(   t   DisallowedHostt   ImproperlyConfiguredt   RequestDataTooBig(   t   uploadhandler(   t   MultiPartParsert   MultiPartParserError(   t   six(   t   ImmutableListt   MultiValueDict(   t   escape_uri_patht   force_bytest	   force_strt
   force_textt
   iri_to_uri(   t   is_same_domaint   limited_parse_qsl(   t   quotet	   urlencodet   urljoint   urlsplitu1   ^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9\.:]+\])(:\d+)?$t   UnreadablePostErrorc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR      s   t   RawPostDataExceptionc           B  s   e  Z d  Z RS(   uŽ   
    You cannot access raw_post_data from a request that has
    multipart/* POST data if it has been accessed via POST,
    FILES, etc..
    (   R   R   t   __doc__(    (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR   "   s   t   HttpRequestc           B  sL  e  Z d  Z d Z g  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e d „ Z e d d d „ Z d	 „  Z d d
 „ Z d „  Z e d „  ƒ Z d „  Z d „  Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! e! Z" d „  Z# RS(   u   A basic HTTP request.c         C  s…   t  d t ƒ |  _ t  d t ƒ |  _ i  |  _ i  |  _ t ƒ  |  _ d |  _ d |  _	 d  |  _ d  |  _ t |  _ d  |  _ d  |  _ d  S(   Nt   mutableu    (   t	   QueryDictt   Truet   GETt   POSTt   COOKIESt   METAR   t   FILESt   patht	   path_infot   Nonet   methodt   resolver_matcht   Falset   _post_parse_errort   content_typet   content_params(   t   self(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   __init__2   s    								c         C  s\   |  j  d  k s |  j ƒ  r0 t d |  j j ƒ St d |  j j |  j  t |  j ƒ  ƒ f ƒ S(   Nu   <%s>u   <%s: %s %r>(   R*   R)   t   get_full_pathR   t	   __class__R   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   __repr__E   s    c         C  s•   t  j r( d |  j k r( |  j d } ni d |  j k rG |  j d } nJ |  j d } |  j ƒ  } | |  j ƒ  ru d n d k r‘ d | | f } n  | S(   u—   
        Return the HTTP host using the environment or request headers. Skip
        allowed hosts protection, so may return an insecure host.
        u   HTTP_X_FORWARDED_HOSTu	   HTTP_HOSTu   SERVER_NAMEu   443u   80u   %s:%s(   R   t   USE_X_FORWARDED_HOSTR%   t   get_portt	   is_secure(   R0   t   hostt   server_port(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _get_raw_hostL   s    	c         C  s   |  j  ƒ  } t j } t j r7 | r7 d d d g } n  t | ƒ \ } } | rb t | | ƒ rb | Sd | } | rƒ | d | 7} n
 | d 7} t | ƒ ‚ d S(   u>   Return the HTTP host using the environment or request headers.u	   localhostu	   127.0.0.1u   [::1]u   Invalid HTTP_HOST header: %r.u)    You may need to add %r to ALLOWED_HOSTS.uB    The domain name provided is not valid according to RFC 1034/1035.N(   R:   R   t   ALLOWED_HOSTSt   DEBUGt   split_domain_portt   validate_hostR   (   R0   R8   t   allowed_hostst   domaint   portt   msg(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   get_host_   s    	

c         C  s?   t  j r( d |  j k r( |  j d } n |  j d } t | ƒ S(   u3   Return the port number for the request as a string.u   HTTP_X_FORWARDED_PORTu   SERVER_PORT(   R   t   USE_X_FORWARDED_PORTR%   t   str(   R0   RA   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR6   s   s    c         C  sm   d t  |  j ƒ | r. |  j j d ƒ r. d n d |  j j d d ƒ re d t |  j j d d ƒ ƒ n d f S(   Nu   %s%s%su   /u    u   QUERY_STRINGu   ?(   R   R'   t   endswithR%   t   getR   (   R0   t   force_append_slash(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR2   {   s    "u    c         C  s   y |  j  | } Wn$ t k
 r7 | t k	 r1 | S‚  n Xy) t j d | | ƒ j | d | ƒ} Wn' t j k
 rŠ | t k	 r„ | S‚  n X| S(   ué   
        Attempts to return a signed cookie. If the signature fails or the
        cookie has expired, raises an exception... unless you provide the
        default argument in which case that value will be returned instead.
        t   saltt   max_age(   R$   t   KeyErrort   RAISE_ERRORR   t   get_cookie_signert   unsignt   BadSignature(   R0   t   keyt   defaultRI   RJ   t   cookie_valuet   value(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   get_signed_cookie„   s    c         C  s+   d j  d |  j d |  j ƒ  d |  j ƒ  ƒ S(   u•   
        Return an absolute URI from variables available in this request. Skip
        allowed hosts protection, so may return insecure URI.
        u   {scheme}://{host}{path}t   schemeR8   R'   (   t   formatRU   R:   R2   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   get_raw_uri›   s    		c         C  sƒ   | d k r d |  j ƒ  } n  t | ƒ } | j o: | j sy d j d |  j d |  j ƒ  d |  j ƒ } t | | ƒ } n  t	 | ƒ S(   uì  
        Builds an absolute URI from the location and the variables available in
        this request. If no ``location`` is specified, the absolute URI is
        built on ``request.get_full_path()``. Anyway, if the location is
        absolute, it is simply converted to an RFC 3987 compliant URI and
        returned and if location is relative or is scheme-relative (i.e.,
        ``//example.com/``), it is urljoined to a base URL constructed from the
        request variables.
        u   //%su   {scheme}://{host}{path}RU   R8   R'   N(
   R)   R2   R   RU   t   netlocRV   RC   R'   R   R   (   R0   t   locationt   bitst   current_uri(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   build_absolute_uri¦   s    
c         C  s   d S(   ug   
        Hook for subclasses like WSGIRequest to implement. Returns 'http' by
        default.
        u   http(    (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _get_scheme¿   s    c         C  s{   t  j rq y t  j \ } } Wn t k
 r; t d ƒ ‚ n X|  j j | ƒ } | d  k	 rq | | k rj d Sd Sn  |  j ƒ  S(   NuJ   The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.u   httpsu   http(   R   t   SECURE_PROXY_SSL_HEADERt
   ValueErrorR   R%   RG   R)   R]   (   R0   t   headert   secure_valuet   header_value(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRU   Æ   s    	c         C  s   |  j  d k S(   Nu   https(   RU   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR7   Ô   s    c         C  s   |  j  j d ƒ d k S(   Nu   HTTP_X_REQUESTED_WITHu   XMLHttpRequest(   R%   RG   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   is_ajax×   s    c         C  s   |  j  S(   N(   t	   _encoding(   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   encodingÚ   s    c         C  s=   | |  _  t |  d ƒ r! |  ` n  t |  d ƒ r9 |  ` n  d S(   uÙ   
        Sets the encoding used for GET/POST accesses. If the GET or POST
        dictionary has already been created, it is removed and recreated on the
        next access (so that it is decoded correctly).
        u   GETu   _postN(   Rd   t   hasattrR"   t   _post(   R0   t   val(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRe   Þ   s
    		c         C  s/   g  t  j D] } t j | |  ƒ ^ q
 |  _ d  S(   N(   R   t   FILE_UPLOAD_HANDLERSR   t   load_handlert   _upload_handlers(   R0   t   handler(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _initialize_handlersë   s    c         C  s   |  j  s |  j ƒ  n  |  j  S(   N(   Rk   Rm   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   upload_handlersï   s    	c         C  s+   t  |  d ƒ r t d ƒ ‚ n  | |  _ d  S(   Nu   _filesuG   You cannot set the upload handlers after the upload has been processed.(   Rf   t   AttributeErrorRk   (   R0   Rn   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRn   ö   s    c         C  s=   t  |  j d d ƒ|  _ t | | |  j |  j ƒ } | j ƒ  S(   u:   Returns a tuple of (POST QueryDict, FILES MultiValueDict).t   warninguE   You cannot alter upload handlers after the upload has been processed.(   R   Rn   R	   Re   t   parse(   R0   R%   t	   post_datat   parser(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   parse_file_uploadü   s
    	c         C  s×   t  |  d ƒ sÐ |  j r' t d ƒ ‚ n  t j d  k	 rl t |  j j d ƒ pN d ƒ t j k rl t	 d ƒ ‚ n  y |  j
 ƒ  |  _ Wn9 t k
 rº } t j t t | j Œ  t j ƒ  d ƒ n Xt |  j ƒ |  _ n  |  j S(   Nu   _bodyu?   You cannot access body after reading from request's data streamu   CONTENT_LENGTHi    u;   Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.i   (   Rf   t   _read_startedR   R   t   DATA_UPLOAD_MAX_MEMORY_SIZER)   t   intR%   RG   R   t   readt   _bodyt   IOErrorR   t   reraiseR   t   argst   syst   exc_infoR   t   _stream(   R0   t   e(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   body  s    	'*c         C  s%   t  ƒ  |  _ t ƒ  |  _ t |  _ d  S(   N(   R    Rg   R   t   _filesR!   R-   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _mark_post_parse_error  s    c         C  s;  |  j  d k r5 t d |  j ƒ t ƒ  |  _ |  _ d S|  j r\ t |  d ƒ r\ |  j ƒ  d S|  j	 d k rÛ t |  d ƒ rŒ t
 |  j ƒ } n |  } y% |  j |  j | ƒ \ |  _ |  _ Wq7t k
 r× |  j ƒ  ‚  q7Xn\ |  j	 d k rt |  j d |  j ƒt ƒ  |  _ |  _ n" t d |  j ƒ t ƒ  |  _ |  _ d S(   uF   Populate self._post and self._files if the content-type is a form typeu   POSTRe   Nu   _bodyu   multipart/form-datau!   application/x-www-form-urlencoded(   R*   R    Rd   R   Rg   R‚   Ru   Rf   Rƒ   R.   R   Ry   Rt   R%   R
   R   (   R0   t   data(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _load_post_and_files  s$    "
%

+c         C  sM   t  |  d ƒ rI x7 t j d „  |  j j ƒ  Dƒ ƒ D] } | j ƒ  q2 Wn  d  S(   Nu   _filesc         s  s   |  ] } | d  Vq d S(   i   N(    (   t   .0t   l(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pys	   <genexpr>>  s    (   Rf   R   t   from_iterableR‚   t   listst   close(   R0   t   f(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRŠ   <  s    )c         O  s`   t  |  _ y |  j j | | Ž  SWn9 t k
 r[ } t j t t | j Œ  t	 j
 ƒ  d ƒ n Xd  S(   Ni   (   R!   Ru   R   Rx   Rz   R   R{   R   R|   R}   R~   (   R0   R|   t   kwargsR€   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRx   I  s
    	c         O  s`   t  |  _ y |  j j | | Ž  SWn9 t k
 r[ } t j t t | j Œ  t	 j
 ƒ  d ƒ n Xd  S(   Ni   (   R!   Ru   R   t   readlineRz   R   R{   R   R|   R}   R~   (   R0   R|   RŒ   R€   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR   P  s
    	c         c  s,   x% t  r' |  j ƒ  } | s Pn  | Vq Wd  S(   N(   R!   R   (   R0   t   buf(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt
   xreadlinesW  s
    	c         C  s   t  t |  ƒ ƒ S(   N(   t   listt   iter(   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt	   readlines`  s    N($   R   R   R   R)   Rd   Rk   R1   R4   R:   RC   R6   R,   R2   RL   RT   RW   R\   R]   t   propertyRU   R7   Rc   Re   t   setterRm   Rn   Rt   R   Rƒ   R…   RŠ   Rx   R   R   t   __iter__R’   (    (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR   +   s>   															 				R    c           B  sì   e  Z d  Z e Z d Z d e d d „ Z e	 d e d d „ ƒ Z
 e d „  ƒ Z e j d „  ƒ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d d „ Z RS(   uÿ  
    A specialized MultiValueDict which represents a query string.

    A QueryDict can be used to represent GET or POST data. It subclasses
    MultiValueDict since keys in such data can be repeated, for instance
    in the data from a form with a <select multiple> field.

    By default QueryDicts are immutable, though the copy() method
    will always return a mutable copy.

    Both keys and values set on this class are converted from the given encoding
    (DEFAULT_CHARSET by default) to unicode.
    c         C  s^  t  t |  ƒ j ƒ  | s% t j } n  | |  _ | p7 d } i t d 6t j d 6| d 6} t j	 rÜ t
 | t ƒ r© y | j | ƒ } Wq© t k
 r¥ | j d ƒ } q© Xn  x¥ t | |  D] \ } } |  j | | ƒ q¹ Wnu xr t | |  D]a \ } } y | j | ƒ } Wn  t k
 r-| j d ƒ } n X|  j t | | d d ƒ| ƒ qì W| |  _ d  S(   Nu    u   keep_blank_valuesu   fields_limitu   encodingu
   iso-8859-1t   errorsu   replace(   t   superR    R1   R   t   DEFAULT_CHARSETRe   R!   t   DATA_UPLOAD_MAX_NUMBER_FIELDSR   t   PY3t
   isinstancet   bytest   decodet   UnicodeDecodeErrorR   t
   appendlistR   t   _mutable(   R0   t   query_stringR   Re   t   parse_qsl_kwargsRP   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR1   x  s2    	

	u    c         C  sO   |  d d t  d | ƒ} x | D] } | j | | ƒ q W| sK t | _ n  | S(   ut   
        Return a new QueryDict with keys (may be repeated) from an iterable and
        values from value.
        u    R   Re   (   R!   RŸ   R,   R    (   t   clst   iterableRS   R   Re   t   qRP   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   fromkeys—  s    c         C  s%   |  j  d  k r t j |  _  n  |  j  S(   N(   Rd   R)   R   R˜   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRe   ¤  s    c         C  s   | |  _  d  S(   N(   Rd   (   R0   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRe   ª  s    c         C  s   |  j  s t d ƒ ‚ n  d  S(   Nu$   This QueryDict instance is immutable(   R    Ro   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   _assert_mutable®  s    	c         C  sK   |  j  ƒ  t | |  j ƒ } t | |  j ƒ } t t |  ƒ j | | ƒ d  S(   N(   R§   t   bytes_to_textRe   R—   R    t   __setitem__(   R0   RP   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR©   ²  s    
c         C  s$   |  j  ƒ  t t |  ƒ j | ƒ d  S(   N(   R§   R—   R    t   __delitem__(   R0   RP   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRª   ¸  s    
c         C  sR   |  j  d d t d |  j ƒ} x- t j |  ƒ D] \ } } | j | | ƒ q. W| S(   Nu    R   Re   (   R3   R!   Re   R   t	   iterlistst   setlist(   R0   t   resultRP   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   __copy__¼  s    c         C  sz   |  j  d d t d |  j ƒ} | | t |  ƒ <xE t j |  ƒ D]4 \ } } | j t j | | ƒ t j | | ƒ ƒ q> W| S(   Nu    R   Re   (	   R3   R!   Re   t   idR   R«   R¬   t   copyt   deepcopy(   R0   t   memoR­   RP   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   __deepcopy__Â  s
    ,c         C  s^   |  j  ƒ  t | |  j ƒ } g  | D] } t | |  j ƒ ^ q# } t t |  ƒ j | | ƒ d  S(   N(   R§   R¨   Re   R—   R    R¬   (   R0   RP   t   list_t   elt(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¬   É  s    
%c         C  s#   |  j  ƒ  t t |  ƒ j | | ƒ S(   N(   R§   R—   R    t   setlistdefault(   R0   RP   t   default_list(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¶   Ï  s    
c         C  sK   |  j  ƒ  t | |  j ƒ } t | |  j ƒ } t t |  ƒ j | | ƒ d  S(   N(   R§   R¨   Re   R—   R    RŸ   (   R0   RP   RS   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRŸ   Ó  s    
c         G  s#   |  j  ƒ  t t |  ƒ j | | Œ S(   N(   R§   R—   R    t   pop(   R0   RP   R|   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¸   Ù  s    
c         C  s   |  j  ƒ  t t |  ƒ j ƒ  S(   N(   R§   R—   R    t   popitem(   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¹   Ý  s    
c         C  s!   |  j  ƒ  t t |  ƒ j ƒ  d  S(   N(   R§   R—   R    t   clear(   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyRº   á  s    
c         C  sG   |  j  ƒ  t | |  j ƒ } t | |  j ƒ } t t |  ƒ j | | ƒ S(   N(   R§   R¨   Re   R—   R    t
   setdefault(   R0   RP   RQ   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR»   å  s    
c         C  s   |  j  i  ƒ S(   u&   Returns a mutable copy of this object.(   R³   (   R0   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR°   ë  s    c           s˜   g  } ˆ r0 t  ˆ ˆ j ƒ ‰ ‡ f d †  ‰  n	 d „  ‰  xO ˆ j ƒ  D]A \ ‰ } t  ˆ ˆ j ƒ ‰ | j ‡  ‡ ‡ f d †  | Dƒ ƒ qF Wd j | ƒ S(   u˜  
        Returns an encoded string of all query string arguments.

        :arg safe: Used to specify characters which do not require quoting, for
            example::

                >>> q = QueryDict(mutable=True)
                >>> q['next'] = '/a&b/'
                >>> q.urlencode()
                'next=%2Fa%26b%2F'
                >>> q.urlencode(safe='/')
                'next=/a%26b/'
        c           s    d t  |  ˆ  ƒ t  | ˆ  ƒ f S(   Nu   %s=%s(   R   (   t   kt   v(   t   safe(    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   encode  s    c         S  s   t  i | |  6ƒ S(   N(   R   (   R¼   R½   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¿     s    c         3  s*   |  ]  } ˆ  ˆ t  | ˆ j ƒ ƒ Vq d  S(   N(   R   Re   (   R†   R½   (   R¿   R¼   R0   (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pys	   <genexpr>  s   u   &(   R   Re   R‰   t   extendt   join(   R0   R¾   t   outputR´   (    (   R¿   R¼   R¾   R0   s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR   ï  s    	N(   R   R   R   R!   R    R)   Rd   R,   R1   t   classmethodR¦   R“   Re   R”   R§   R©   Rª   R®   R³   R¬   R¶   RŸ   R¸   R¹   Rº   R»   R°   R   (    (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR    d  s,   											c         C  s*   t  |  t ƒ r" t j |  | d ƒ S|  Sd S(   uã   
    Converts basestring objects to unicode, using the given encoding. Illegally
    encoded input characters are replaced with Unicode "unknown" codepoint
    (ï¿½).

    Returns any non-basestring objects without change.
    u   replaceN(   R›   Rœ   R   t	   text_type(   t   sRe   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR¨     s    c         C  s¢   |  j  ƒ  }  t j |  ƒ s d	 S|  d d k r9 |  d f S|  j d d ƒ } t | ƒ d k rc | n | d d f \ } } | j d ƒ r’ | d  n | } | | f S(
   u•   
    Return a (domain, port) tuple from a given host.

    Returned domain is lower-cased. If the host is invalid, the domain will be
    empty.
    u    iÿÿÿÿu   ]u   :i   i   i    u   .(   u    u    (   t   lowert   host_validation_ret   matcht   rsplitt   lenRF   (   R8   RZ   R@   RA   (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR=     s    
.c         C  s4   x- | D]% } | d k s( t  |  | ƒ r t Sq Wt S(   u5  
    Validate the given host for this site.

    Check that the host looks valid and matches a host or host pattern in the
    given list of ``allowed_hosts``. Any pattern beginning with a period
    matches a domain and all its subdomains (e.g. ``.example.com`` matches
    ``example.com`` and any subdomain), ``*`` matches anything, and anything
    else must match exactly.

    Note: This function assumes that the given host is lower-cased and has
    already had the port, if any, stripped off.

    Return ``True`` for a valid host, ``False`` otherwise.
    u   *(   R   R!   R,   (   R8   R?   t   pattern(    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyR>   4  s    (6   t
   __future__R    R°   t   reR}   t   ioR   t	   itertoolsR   t   django.confR   t   django.coreR   t   django.core.exceptionsR   R   R   t   django.core.filesR   t   django.http.multipartparserR	   R
   t   django.utilsR   t   django.utils.datastructuresR   R   t   django.utils.encodingR   R   R   R   R   t   django.utils.httpR   R   t#   django.utils.six.moves.urllib.parseR   R   R   R   t   objectRL   t   compileRÇ   Rz   R   t	   ExceptionR   R   R    R¨   R=   R>   (    (    (    s=   /usr/local/lib/python2.7/dist-packages/django/http/request.pyt   <module>   s2   ("		ÿ :¬		