U!\c@s!ddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddl ZddlmZddlmZmZmZmZmZddlmZejeZd efd YZd efd YZd ee fdYZdeefdYZde fdYZ de fdYZ!dddZ#dZ$dZ%defdYZ&defdYZ'defdYZ(defdYZ)d efd!YZ*d"ej+fd#YZ,dS($iN(tVerifiedHTTPSConnection(tHTTPConnection(tHTTPConnectionPool(tHTTPSConnectionPool(tsix(t HTTPHeaderst HTTPResponset urlunsplitturlsplitt urlencode(tUnseekableStreamErrortAWSHTTPResponsecBseZdZdZRS(cOs)|jd|_tj|||dS(Nt status_tuple(tpopt _status_tupleRt__init__(tselftargstkwargs((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR'scCs6|jdk r%|j}d|_|Stj|SdS(N(RtNoneRt _read_status(RR ((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR+s   (t__name__t __module__RR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR $s t AWSConnectioncBsteZdZdZdZdZdZdZd dZ dZ dZ d Z d Z d ZRS( sMixin for HTTPConnection that supports Expect 100-continue. This when mixed with a subclass of httplib.HTTPConnection (though technically we subclass from urllib3, which subclasses httplib.HTTPConnection) and we only override this class to support Expect 100-continue, which we need for S3. As far as I can tell, this is general purpose enough to not be specific to S3, but I'm being tentative and keeping it in botocore because I've only tested this against AWS services. cOs;tt|j|||j|_t|_t|_dS(N(tsuperRRtresponse_classt_original_response_clstFalset_response_receivedt_expect_header_set(RRR((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR@s cCs5tt|jt|_t|_|j|_dS(N(RRtcloseRRRRR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRNs  cCsHtjd d kr&tt|jS|j|j|j|jd|j |j fx4|j j D]#\}}|jd||fqiW|jd|j |jd|jd|j}|j\}}}|dkr|jtjd ||jfnx3trC|jj}|s0Pn|d krPqqWdS(NiisCONNECT %s:%d HTTP/1.0 s%s: %s s tstricttmethodisTunnel connection failed: %d %ss t(ii(s s R!(tsyst version_infoRRt_tunnelt _set_hostportt _tunnel_hostt _tunnel_porttsendthosttportt_tunnel_headerst iteritemsRtsockRt_methodRRtsocketterrortstriptTruetfptreadline(Rtheadertvaluetresponsetversiontcodetmessagetline((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR$Us(       cOsvt|_|jdddkr-t|_nt|_|j|_tt|j ||||||}t|_|S(NtExpectR!s 100-continue( RRtgetR2RRRRRt _send_request(RR turltbodytheadersRRtrval((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR>us     cCsbg}xF|D]>}t|tjr>|j|jdq |j|q Wdj|}|S(Nsutf-8s (t isinstanceRt text_typetappendtencodetjoin(Rt mixed_buffert bytes_buffertchunktmsg((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt_convert_to_bytess cOs|jjd|j|j}|j2t|trK||7}d}n|j||jrtj dt j j |j dr|j|dStj dn|dk r|j|ndS(NR!s"Waiting for 100 Continue response.isCNo response seen from server, continuing to send the response body.(R!R!(t_buffertextendRLRCtbytesRR(Rtloggertdebugturllib3tutilt wait_for_readR-t_handle_expect_response(Rt message_bodyRRRK((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt _send_outputs        cCs)d}x|dkr$|j}q WdS(Ns (RR4(RR3tcurrent((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt_consume_headersscCs|jjdd}z|j}|jdd}|j|ro|j|tjd|j |nt |dkr|dj drtjd|dj dt |d |dj df}tjtd |}||_t|_nWd|jXdS( Ntrbiis5100 Continue response seen, now sending request body.isHTTP/sOReceived a non 100 Continue response from the server, NOT sending request body.tasciiiR (R-tmakefileR4tsplitRt_is_100_continue_statusRYRPRQt_send_message_bodytlent startswithtdecodetintt functoolstpartialR RR2RR(RRVR3tmaybe_status_linetpartsR R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRUs"   % # cCs |dk r|j|ndS(N(RR((RRV((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR_s cCs0|jrtjddStt|j|S(Ns@send() called, but reseponse already received. Not sending data.(RRPRQRRR((Rtstr((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR(s  cCsE|jdd}t|dkoD|djdoD|ddkS(NiiisHTTP/it100(R]RR`Ra(RRfRg((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR^s%N(RRt__doc__RRR$R>RLRRWRYRUR_R(R^(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR4s    $ %  tAWSHTTPConnectioncBseZdZRS(s8 An HTTPConnection that supports 100 Continue behavior. (RRRj(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRkstAWSHTTPSConnectioncBseZdZRS(s9 An HTTPSConnection that supports 100 Continue behavior. (RRRj(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRlstAWSHTTPConnectionPoolcBseZeZRS((RRRkt ConnectionCls(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRmstAWSHTTPSConnectionPoolcBseZeZRS((RRRlRn(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRosc Cs|}|d k r)|d}||dConstructs a :class:`AWSPreparedRequest `.(RR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRscCs7|jj}t|tjr3|jd}n|S(Nsutf-8(RR@RCRRDRF(RR@((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR@sN( RRRjRRRRRRtpropertyR@(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRs  RcBs)eZdZdZdZdZRS(sA data class representing a finalized request to be sent over the wire. Requests at this stage should be treated as final, and the properties of the request should not be modified. :ivar method: The HTTP Method :ivar url: The full url :ivar headers: The HTTP headers to send. :ivar body: The HTTP body. :ivar stream_output: If the response for this request should be streamed. cCs1||_||_||_||_||_dS(N(R R?RAR@R(RR R?RAR@R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRs     cCs&d}||j|j|j|jfS(NsD(RR R?RA(Rtfmt((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__repr__scCstjtjtf}|jdks6t|j|r:dSy'tjd|j|jj dWn5t k r}tjd|t d|jnXdS(s+Resets the streaming body to it's initial position. If the request contains a streaming body (a streamable file-like object) seek to the object's initial position to ensure the entire contents of the object is sent. This is a no-op for static bytes-like body types. NsRewinding stream: %sisUnable to rewind stream: %st stream_object( Rt binary_typeRDt bytearrayR@RRCRPRQRt ExceptionR (Rtnon_seekable_typesR((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt reset_streams !(RRRjRRR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRs   t AWSResponsecBs5eZdZdZedZedZRS(sA data class representing an HTTP response. This class was originally inspired by requests.models.Response, but has been boiled down to meet the specific use cases in botocore. This has effectively been reduced to a named tuple. :ivar url: The full url. :ivar status_code: The status code of the HTTP response. :ivar headers: The HTTP headers received. :ivar body: The HTTP response body. cCs7||_||_t||_||_d|_dS(N(R?t status_codeRRAtrawRt_content(RR?RRAR((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR:s    cCs@|jdkr9tj|jjp0t|_n|jS(s!Content of the response as bytes.N(RRRORGRtstream(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pytcontentBs*cCs?tjj|j}|r+|jj|S|jjdSdS(s Content of the response as a proper text type. Uses the encoding type provided in the reponse headers to decode the response content into a proper text type. If the encoding is not present in the headers, UTF-8 is used as a default. sutf-8N(RvRwtget_encoding_from_headersRARRb(Rtencoding((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyttextOs(RRRjRRRR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR-s   t _HeaderKeycBs5eZdZdZdZdZdZRS(cCs||_|j|_dS(N(t_keytlowert_lower(RR((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR_s cCs t|jS(N(thashR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__hash__cscCst|to|j|jkS(N(RCRR(Rtother((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__eq__fscCs|jS(N(R(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__str__iscCs t|jS(N(treprR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRls(RRRRRRR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyR^s     RcBsVeZdZdZdZdZdZdZdZdZ dZ RS( s:A case-insenseitive dictionary to represent HTTP headers. cOsi|_|j||dS(N(t_dicttupdate(RRR((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRrs cCs||jt|s(R(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__iter__scCs t|jS(N(R`R(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyt__len__scCs t|jS(N(RR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRscCst|jS(N(RR(R((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pytcopys( RRRjRRRRRRRR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyRps       (-R"tloggingRdR/t collectionst urllib3.utilRRturllib3.connectionRRturllib3.connectionpoolRRtbotocore.utilsRvtbotocore.compatRRRRRR tbotocore.exceptionsR t getLoggerRRPR tobjectRRkRlRmRoRR~RRuRRRRRtMutableMappingR(((s7/tmp/pip-install-usGedi/botocore/botocore/awsrequest.pyts<       ( '  d921