
oTc           @   s>  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 d  d l m Z m Z d e f d     YZ d e f d     YZ d	   Z d
   Z d   Z d   Z d d d d d d d d g Z d e f d     YZ d e f d     YZ d e f d     YZ d S(   iN(   t   _cpcgifst	   _cpconfig(   t
   format_exct
   bare_error(   t   httpt   file_generatort   Hookc           B   sk   e  Z e j Z d	 Z d  Z e Z	 d Z
 d Z d Z i  Z d Z d	 d	 d  Z d   Z d   Z d   Z RS(
   sk   
    The bare callable that this Hook object is wrapping, which will
    be called when the Hook is called.sv   
    If True, the callback is guaranteed to run even if other callbacks
    from the same call point raise exceptions.i2   s   
    Defines the order of execution for a list of Hooks. Priority numbers
    should be limited to the closed interval [0, 100], but values outside
    this range are acceptable, as are fractional values.sU   
    A set of keyword arguments that will be passed to the
    callable on each call.c         K   sj   | |  _  | d  k r* t | d t  } n  | |  _ | d  k rT t | d d  } n  | |  _ | |  _ d  S(   Nt   failsafet   priorityi2   (   t   callbackt   Nonet   getattrt   FalseR   R   t   kwargs(   t   selfR	   R   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __init__(   s    			c         C   s   t  |  j | j  S(   N(   t   cmpR   (   R   t   other(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __cmp__5   s    c         C   s   |  j  |  j   S(   N(   R	   R   (   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __call__8   s    c         C   sg   |  j  } d | j | j |  j |  j |  j d j g  |  j j   D] \ } } d | | f ^ q@  f S(   Ns0   %s.%s(callback=%r, failsafe=%r, priority=%r, %s)s   , s   %s=%r(	   t	   __class__t
   __module__t   __name__R	   R   R   t   joinR   t	   iteritems(   R   t   clst   kt   v(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __repr__<   s    		N(   R   R   t   cherrypyt   _AttributeDocstringst   __metaclass__R
   R	   t   callback__docR   R   t   failsafe__docR   t   priority__docR   t   kwargs__docR   R   R   R   (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR      s   			t   HookMapc           B   sM   e  Z d d   Z d   Z d d d  Z d   Z d   Z e Z d   Z	 RS(   c         C   s4   t  j |   } x | p g  D] } g  | | <q W| S(   N(   t   dictt   __new__(   R   t   pointst   dt   p(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR&   H   s    c         O   s   d  S(   N(    (   R   t   at   kw(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR   N   s    c         K   s$   |  | j  t | | | |   d  S(   N(   t   appendR   (   R   t   pointR	   R   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   attachQ   s    c         C   s   d  } |  | } | j   x | D] } | d  k s< | j r! y |   Wq t t f k
 rc   q t j t j t j f k
 r t	 j
   d } q t	 j
   d } t j d t d d  q Xq! q! W| r   n  d  S(   Ni   t	   tracebackt   severityi(   (   R
   t   sortR   t   KeyboardInterruptt
   SystemExitR   t	   HTTPErrort   HTTPRedirectt   InternalRedirectt   syst   exc_infot   logt   True(   R   R-   t   exct   hookst   hook(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   runU   s"    

!c         C   s8   |  j    } x% |  j   D] \ } } | | | <q W| S(   N(   R   R   (   R   t   newmapR   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __copy__n   s    c         C   s&   |  j  } d | j | j |  j   f S(   Ns   %s.%s(points=%r)(   R   R   R   t   keys(   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR   w   s    	N(
   R   R   R
   R&   R   R.   R>   R@   t   copyR   (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR$   E   s   			c         C   ss   |  j  d d  d } t | t  r: t j j |  } n  t | t  sX t |  } n  t j j | j	 |  d  S(   Nt   .i   i    (
   t   splitt
   isinstancet
   basestringR   t   libt
   attributesR   t   requestR<   R,   (   R   R   t	   hookpoint(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   hooks_namespace~   s    c         C   s   t  t j |  |  d  S(   N(   t   setattrR   RI   (   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   request_namespace   s    c         C   s   t  t j |  |  d  S(   N(   RL   R   t   response(   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   response_namespace   s    c         C   s/   |  d k r t  |   }  n  | t j j |  <d  S(   Nt   default(   t   intR   RI   t
   error_page(   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   error_page_namespace   s    t   on_start_resourcet   before_request_bodyt   before_handlert   before_finalizet   on_end_resourcet   on_end_requestt   before_error_responset   after_error_responset   Requestc           B   s  e  Z e j Z d> Z d  Z e j	 d d  Z
 d Z e j	 d d  Z d Z d Z d Z d Z d	 Z d
 Z d Z d
 Z d Z d Z d Z d
 Z d Z d? Z d Z i  Z d Z g  Z d Z e j    Z! d Z" e# j$   Z% d Z& d> Z' d Z( e) Z* d Z+ d@ Z, d Z- d> Z. d Z/ d> Z0 d Z1 e j2 j3   Z2 d Z4 d
 Z5 d Z6 d Z7 d  Z8 d> Z9 d! Z: d> Z; d" Z< d> Z= d# Z> i  Z? d$ Z@ d> ZA d% ZB d> ZC d& ZD eE eF  ZG d' ZH e jI d(  jJ ZK d) ZL i  ZM d* ZN e) ZO d+ ZP e) ZQ d, ZR eS eT e jU f ZV d- ZW eX ZY d. ZZ eX Z[ d/ Z\ d> Z] d0 Z^ e_ j` i ea d1 6eb d2 6ec d3 6ed d4 6e je d5 6  Zf d d d6  Zg d7   Zh d8   Zi d9   Zj d:   Zk d;   Zl d<   Zm d=   Zn RS(A   sp   
    The previous Request object (if any). This should be None
    unless we are processing an InternalRedirect.s	   127.0.0.1iP   s>   An http.Host(ip, port, hostname) object for the server socket.iW  s>   An http.Host(ip, port, hostname) object for the client socket.R   sk   
    The protocol used between client and server. In most cases,
    this will be either 'http' or 'https'.s   HTTP/1.1sX   
    The HTTP version for which the HTTP server is at least
    conditionally compliant.t    s"  The (scheme://host) portion of the requested URL.
    In some cases (e.g. when proxying via mod_rewrite), this may contain
    path segments which cherrypy.url uses when constructing url's, but
    which otherwise are ignored by CherryPy. Regardless, this value
    MUST NOT end in a slash.s   
    The complete Request-Line received from the client. This is a
    single string consisting of the request method, URI, and protocol
    version (joined by spaces). Any final CRLF is removed.t   GETsf  
    Indicates the HTTP method to be performed on the resource identified
    by the Request-URI. Common methods include GET, HEAD, POST, PUT, and
    DELETE. CherryPy allows any extension method; however, various HTTP
    servers and gateways may restrict the set of allowable methods.
    CherryPy applications SHOULD restrict the set (on a per-URI basis).s)  
    The query component of the Request-URI, a string of information to be
    interpreted by the resource. The query portion of a URI follows the
    path component, and is separated by a '?'. For example, the URI
    'http://www.cherrypy.org/wiki?a=3&b=4' has the query component,
    'a=3&b=4'.i   s  The HTTP protocol version corresponding to the set
        of features which should be allowed in the response. If BOTH
        the client's request message AND the server's level of HTTP
        compliance is HTTP/1.1, this attribute will be the tuple (1, 1).
        If either is 1.0, this attribute will be the tuple (1, 0).
        Lower HTTP protocol versions are not explicitly supported.s  
    A dict which combines query string (GET) and request entity (POST)
    variables. This is populated in two stages: GET params are added
    before the 'on_start_resource' hook, and POST params are added
    between the 'before_request_body' and 'before_handler' hooks.s   
    A list of the HTTP request headers as (name, value) tuples.
    In general, you should use request.headers (a dict) instead.s  
    A dict-like object containing the request headers. Keys are header
    names (in Title-Case format); however, you may get and set them in
    a case-insensitive manner. That is, headers['Content-Type'] and
    headers['content-type'] refer to the same value. Values are header
    values (decoded according to RFC 2047 if necessary). See also:
    http.HeaderMap, http.HeaderElement.s   See help(Cookie).s  
    If the request included an entity (body), it will be available
    as a stream in this attribute. However, the rfile will normally
    be read for you between the 'before_request_body' hook and the
    'before_handler' hook, and the resulting string is placed into
    either request.params or the request.body attribute.
    
    You may disable the automatic consumption of the rfile by setting
    request.process_request_body to False, either in config for the desired
    path, or in an 'on_start_resource' or 'before_request_body' hook.
    
    WARNING: In almost every case, you should not attempt to read from the
    rfile stream after CherryPy's automatic mechanism has read it. If you
    turn off the automatic parsing of rfile, you should read exactly the
    number of bytes specified in request.headers['Content-Length'].
    Ignoring either of these warnings may result in a hung request thread
    or in corruption of the next (pipelined) request.
    s   
    If True, the rfile (if any) is automatically read and parsed,
    and the result placed into request.params or request.body.t   POSTt   PUTsp   
    A sequence of HTTP methods for which CherryPy will automatically
    attempt to read a body from the rfile.s7  
    If the request Content-Type is 'application/x-www-form-urlencoded'
    or multipart, this will be None. Otherwise, this will contain the
    request entity body as a string; this value is set between the
    'before_request_body' and 'before_handler' hooks (assuming that
    process_request_body is True).s  
    If the request Content-Type is 'application/x-www-form-urlencoded' or
    multipart, this will be a dict of the params pulled from the entity
    body; that is, it will be the portion of request.params that come
    from the message body (sometimes called "POST params", although they
    can be sent with various HTTP method verbs). This value is set between
    the 'before_request_body' and 'before_handler' hooks (assuming that
    process_request_body is True).s  
    The object which looks up the 'page handler' callable and collects
    config for the current request based on the path_info, other
    request attributes, and the application architecture. The core
    calls the dispatcher as early as possible, passing it a 'path_info'
    argument.
    
    The default dispatcher discovers the page handler by matching path_info
    to a hierarchical arrangement of objects, starting at request.app.root.
    See help(cherrypy.dispatch) for more information.s   
    The 'mount point' of the application which is handling this request.
    
    This attribute MUST NOT end in a slash. If the script_name refers to
    the root of the URI, it MUST be an empty string (not "/").
    t   /s   
    The 'relative path' portion of the Request-URI. This is relative
    to the script_name ('mount point') of the application which is
    handling this request.s   
    When authentication is used during the request processing this is
    set to 'False' if it failed and to the 'username' value if it succeeded.
    The default 'None' implies that no authentication happened.s?   The cherrypy.Application object which is handling this request.s  
    The function, method, or other callable which CherryPy will call to
    produce the response. The discovery of the handler and the arguments
    it will receive are determined by the request.dispatch object.
    By default, the handler is discovered by walking a tree of objects
    starting at request.app.root, and is then passed all HTTP params
    (from the query string and POST body) as keyword arguments.s   
    A nested dict of all Toolboxes and Tools in effect for this request,
    of the form: {Toolbox.namespace: {Tool.name: config dict}}.s  
    A flat dict of all configuration entries which apply to the
    current request. These entries are collected from global config,
    application config (based on request.path_info), and from handler
    config (exactly how is governed by the request.dispatch object in
    effect for this request; by default, handler config can be attached
    anywhere in the tree between request.app.root and the final handler,
    and inherits downward).sO  
    This will be True if the current request is mapped to an 'index'
    resource handler (also, a 'default' handler if path_info ends with
    a slash). The value may be used to automatically redirect the
    user-agent to a 'more canonical' URL which either adds or removes
    the trailing slash. See cherrypy.tools.trailing_slash.s  
    A HookMap (dict-like object) of the form: {hookpoint: [hook, ...]}.
    Each key is a str naming the hook point, and each value is a list
    of hooks which will be called at that hook point during this request.
    The list of hooks is generally populated as early as possible (mostly
    from Tools specified in config), but may be extended at any time.
    See also: _cprequest.Hook, _cprequest.HookMap, and cherrypy.tools.i  s  
    The no-arg callable which will handle unexpected, untrapped errors
    during request processing. This is not used for expected exceptions
    (like NotFound, HTTPError, or HTTPRedirect) which are raised in
    response to expected conditions (those should be customized either
    via request.error_page or by overriding HTTPError.set_response).
    By default, error_response uses HTTPError(500) to return a generic
    error response to the user-agent.s  
    A dict of {error code: response filename or callable} pairs.
    
    The error code must be an int representing a given HTTP error code,
    or the string 'default', which will be used if no matching entry
    is found for a given numeric code.
    
    If a filename is provided, the file should contain a Python string-
    formatting template, and can expect by default to receive format 
    values with the mapping keys %(status)s, %(message)s, %(traceback)s,
    and %(version)s. The set of format mappings can be extended by
    overriding HTTPError.set_response.
    
    If a callable is provided, it will be called by default with keyword 
    arguments 'status', 'message', 'traceback', and 'version', as for a
    string-formatting template. The callable must return a string which
    will be set to response.body. It may also override headers or perform
    any other processing.
    
    If no entry is given for an error code, and no 'default' entry exists,
    a default template will be used.
    sx   
    If True, unexpected errors encountered during request processing will
    include a traceback in the response body.s   
    If True, mismatched parameters encountered during PageHandler invocation
    processing will be included in the response body.s;   The sequence of exceptions which Request.run does not trap.s   
    If True, Request.run will not trap any errors (except HTTPRedirect and
    HTTPError, which are more properly called 'exceptions', not errors).sA   
    True once the close method has been called, False otherwise.s   
    A string containing the stage reached in the request-handling process.
    This is useful when debugging a live server with hung requests.R<   RI   RN   RR   t   toolsc         C   s^   | |  _  | |  _ | |  _ | |  _ t |  _ |  j j   |  _ |  j j   |  _ d  |  _
 d  S(   N(   t   localt   remotet   schemet   server_protocolR   t   closedRR   RB   t
   namespacesR
   t   stage(   R   t
   local_hostt   remote_hostRe   Rf   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s    					c         C   s;   |  j  s7 t |  _  d |  _ |  j j d  d |  _ n  d  S(   NRY   t   close(   Rg   R:   Ri   R<   R>   (   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyRl     s
    			c         C   sJ  d |  _  yFt j d  j |  _ | |  _ | p3 d } | p? d |  _ t | d  t | d  f } t |  j d  t |  j d  f } t	 | |  |  _
 | }	 | r |	 d | 7}	 n  d | |	 | f |  _ t |  |  _ | |  _ t j   |  _ t j   |  _ d  |  _ |  j j |  _ | t |  j  |  _ }
 d	 |  _  |  j |
  Wn |  j k
 rh  nt |  j rz  qt j d
 t d d  |  j  rt!   } n d } t" |  } t j# } | \ | _$ | _ | _% n X|  j d k rg  t j# _% n  y t j j&   Wn t j j' d
 t  n Xt j# j( rCt j)    n  t j# S(   NR>   i  Ra   R]   i   i   t   ?s   %s %s %st   respondR/   R0   i(   t   HEAD(*   Ri   R   R4   t   set_responset   error_responset   methodt   query_stringRQ   Rf   t   mint   protocolt   request_linet   listt   header_listt   rfileR   t	   HeaderMapt   headerst   Cookiet   SimpleCookiet   cookieR
   t   handlert   appt   script_namet   lent	   path_infoRn   t   throwst   throw_errorsR9   R:   t   show_tracebacksR   R   RN   t   statust   bodyt   accesst   errort	   timed_outt   TimeoutError(   R   Rr   t   pathRs   t   req_protocolR{   Ry   t   rpt   spt   urlt   piR   t   rRN   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR>     sV    		 &						c         C   s  yzyQ|  j  d  k r' t j    n  d |  _ |  j   |  j j j   |  _ i  |  _	 d |  _ |  j
 |  |  j |  j  d |  _ |  j j d  |  j r |  j |  j k r t |  _ q n  d |  _ |  j j d  |  j r |  j   n  d |  _ |  j j d  |  j r0d |  _ |  j   t j _ n  d |  _ |  j j d  t j j   WnO t j t j f k
 r} | j   d |  _ |  j j d  t j j   n XWd  d	 |  _ |  j j d	  XWn6 |  j k
 r  n  |  j r  n  |  j   n Xd  S(
   Nt   process_headerst   get_resourceRT   RU   RV   R   RW   s   before_finalize (HTTPError)RX   (   R   R
   R   t   NotFoundRi   R   R   R<   RB   t   toolmapsR   Rh   t   configR>   t   process_request_bodyRr   t   methods_with_bodiesR   t   process_bodyR   RN   R   t   finalizeR5   R4   Rp   R   R   t   handle_error(   R   R   t   inst(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyRn   G  sT    	
										
			c         C   sG  t  j |  j  |  _ |  j } x |  j D] \ } } | j   } | j   } d | k rw t j	 | | t  j
 |   n t j	 | | |  | d k r( y |  j j |  Wq q Xq( q( Wt j | d  s |  j d k r d } t j d |   q n  t j | d  } | s-|  j j p'|  j j } n  d |  j | f |  _ d  S(	   Ns   =?R|   t   Hosti   s*   HTTP/1.1 requires a 'Host' request header.i  s   %s://%s(   i   i   (   R   t   parse_query_stringRs   t   paramsR{   Rx   t   titlet   stripR%   t   __setitem__t   decode_TEXTR~   t   loadt   __contains__Ru   R   R4   t   getRc   t   namet   ipRe   t   base(   R   R{   R   t   valuet   msgt   host(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR   ~  s*    	c         C   s   |  j  } | p d } x | r |  j j j | i   } | j d  } | rU | } Pn  | j d  } | d k rt Pq | d k r | d k r d } q | |  } q W| |  d  S(   NRa   s   request.dispatchii    (   t   dispatchR   R   R   t   rfind(   R   R   R   t   trailt   nodeconfR(   t	   lastslash(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s    			c      	   C   s  |  j  j d d  s' t j d   n  d |  j  k r[ t j |  j  j    } d | d <n	 |  j  } y2 t j d |  j	 d | d i d d	 6d
 d  } Wn: t
 k
 r } | j j d k r t j d   q   n X| j r | j |  _ n& t j |  |  _ } |  j j |  d  S(   Ns   Content-LengthR]   i  s   Content-Typet   fpR{   t   environR_   t   REQUEST_METHODt   keep_blank_valuesi   t   MaxSizeExceededi  (   R{   R   R   R4   R   Rz   t   itemsR    t   FieldStorageRy   t	   ExceptionR   R   t   fileR   t   params_from_CGI_formt   body_paramsR   t   update(   R   t   ht   formst   eR)   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s&    
		c         C   s{   yG |  j  j d  |  j r) |  j   n  |  j  j d  t j j   Wn- t j k
 rv } | j   t j j   n Xd  S(   NRZ   R[   (   R<   R>   Rq   R   RN   R   R5   Rp   (   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s    	
N(   i   i   (   R_   R`   (o   R   R   R   R   R   R
   t   prevt	   prev__docR   R   Rc   t
   local__docRd   t   remote__docRe   t   scheme__docRf   t   server_protocol__docR   t	   base__docRv   t   request_line__docRr   t   method__docRs   t   query_string__docRu   t   protocol__docR   t   params__docRx   t   header_list__docRz   R{   t   headers__docR|   R}   R~   t   cookie__docRy   t
   rfile__docR:   R   t   process_request_body__docR   t   methods_with_bodies__docR   t	   body__docR   t   body_params__docR   t
   Dispatchert   dispatch__docR   t   script_name__docR   t   path_info__doct   logint
   login__docR   t   app__docR   t   handler__docR   t   toolmaps__docR   t   config__doct   is_indext   is_index__docR$   t
   hookpointsR<   t
   hooks__docR4   Rp   Rq   t   error_response__docRR   t   error_page__docR   t   show_tracebacks__doct   show_mismatched_paramst   show_mismatched_params__docR2   R3   R6   R   t   throws__docR   R   t   throw_errors__docRg   t   closed__docRi   t
   stage__docR   t   NamespaceSetRK   RM   RO   RS   Rb   Rh   R   Rl   R>   Rn   R   R   R   R   (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR\      s   	

		]	7	(		0t   Bodyc           B   s   e  Z d d   Z d   Z RS(   c         C   s   | d  k r |  S| j Sd  S(   N(   R
   t   _body(   R   t   objt   objclass(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __get__   s    c         C   sm   t  | t  r* | r! | g } q` g  } n6 t  | t j  rK t |  } n | d  k r` g  } n  | | _ d  S(   N(   RE   RF   t   typest   FileTypeR   R
   R   (   R   R   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   __set__  s    		N(   R   R   R
   R   R   (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s   t   Responsec           B   s   e  Z e j Z d  Z d Z g  Z d Z e	 j
   Z d Z e j   Z d Z e   Z d Z d Z d Z d Z d Z e Z d	 Z e Z d
 Z d   Z d   Z d   Z  d   Z! RS(   R]   s'   The HTTP Status-Code and Reason-Phrase.s   
    A list of the HTTP response headers as (name, value) tuples.
    In general, you should use response.headers (a dict) instead.s  
    A dict-like object containing the response headers. Keys are header
    names (in Title-Case format); however, you may get and set them in
    a case-insensitive manner. That is, headers['Content-Type'] and
    headers['content-type'] refer to the same value. Values are header
    values (decoded according to RFC 2047 if necessary). See also:
    http.HeaderMap, http.HeaderElement.s   See help(Cookie).s'   The body (entity) of the HTTP response.s9   The value of time.time() when created. Use in HTTP dates.i,  s1   Seconds after which the response will be aborted.s^   
    Flag to indicate the response should be aborted, because it has
    exceeded its timeout.s#   If False, buffer the response body.c         C   s   d  |  _ d  |  _ g  |  _ t j   |  _ t j   |  _ t j	 |  j i d d 6d t
 j d 6t j |  j  d 6 t j   |  _ d  S(   Ns	   text/htmls   Content-Types	   CherryPy/t   Servert   Date(   R
   R   Rx   R   t   timeR   Rz   R{   R%   R   R   t   __version__t   HTTPDateR|   R}   R~   (   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR   J  s    			c         C   s2   d j  g  |  j D] } | ^ q  } | |  _ | S(   NR]   (   R   R   (   R   t   chunkt   newbody(    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   collapse_bodyZ  s    %	c         C   s  y t  j |  j  \ } } } Wn, t k
 rM } t j d | j d   n Xd | | f |  _ |  j } |  j r t	 j
 | d  d  k rt	 j | d d   qnw | d k  s | d k r t	 j | d d   d	 |  _ n@ t	 j
 | d  d  k r|  j   } t	 j | d t |   n  | j t j j  |  _ } |  j j   } | rxa | j d
  D]M }	 |	 j d  r~|	 d  }	 n  |	 j d d  \ }
 } | j |
 | f  q\Wn  d  S(   Ni  i    s   %s %ss   Content-Lengthi   i   i   i0  R]   s   
s   is   : i   (   i   i   i0  (   R   t   valid_statusR   t
   ValueErrorR   R4   t   argsR{   t   streamR%   R   R
   t   popR   R   R   R   t   outputRI   Ru   Rx   R~   RD   t   endswithR,   (   R   t   codet   reasont   _t   xR{   t   contentR   R~   t   lineR   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR   `  s.    		c         C   s,   t  j    |  j  |  j k r( t |  _ n  d  S(   N(   R   t   timeoutR:   R   (   R   (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   check_timeout  s    N("   R   R   R   R   R   R   t   status__docRx   R   R   Rz   R{   R   R|   R}   R~   R   R   R   R   R
   R   t	   time__docR  t   timeout__docR   R   t   timed_out__docR  t   stream__docR   R   R   R  (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyR     s.   						)(   R|   t   osR7   R   R   R   R    R   t   cherrypy._cperrorR   R   t   cherrypy.libR   R   t   objectR   R%   R$   RK   RM   RO   RS   R   R\   R   R   (    (    (    s'   /var/www/SABnzbd/cherrypy/_cprequest.pyt   <module>   s.   79				  `