>ac@sddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddl Z ddl mZddl mZmZmZmZmZmZmZddlmZejeZd efd YZd efd YZd eefdYZdeefdYZde fdYZ de fdYZ!dddZ#dZ$dZ%defdYZ&defdYZ'defdYZ(defdYZ)d efd!YZ*d"efd#YZ+dS($iN(tVerifiedHTTPSConnection(tHTTPConnection(tHTTPConnectionPool(tHTTPSConnectionPool(tsix(t HTTPHeaderst HTTPResponset urlunsplitturlsplitt urlencodeturlparsetMutableMapping(tUnseekableStreamErrortAWSHTTPResponsecBseZdZdZRS(cOs)|jd|_tj|||dS(Nt status_tuple(tpopt _status_tupleRt__init__(tselftargstkwargs((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR'scCs6|jdk r%|j}d|_|Stj|SdS(N(RtNoneRt _read_status(RR((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR+s   (t__name__t __module__RR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR $s t AWSConnectioncBskeZdZdZdZdZdZd dZdZ dZ dZ d Z d Z RS( 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((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR@s cCs5tt|jt|_t|_|j|_dS(N(RRtcloseRRRRR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR Ns  cOsvt|_|jdddkr-t|_nt|_|j|_tt|j ||||||}t|_|S(NtExpectts 100-continue( RRtgettTrueRRRRRt _send_request(RtmethodturltbodytheadersRRtrval((s4/usr/lib/fence-agents/bundled/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((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt_convert_to_bytesas 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_buffertextendR4R+tbytesRtsendRtloggertdebugturllib3tutilt wait_for_readtsockt_handle_expect_response(Rt message_bodyRRR3((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt _send_outputns        cCs)d}x|dkr$|j}q WdS(Ns (Rtreadline(Rtfptcurrent((s4/usr/lib/fence-agents/bundled/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>tmakefileRBtsplitRt_is_100_continue_statusRER9R:t_send_message_bodytlent startswithtdecodetintt functoolstpartialR RR$RR (RR@RCtmaybe_status_linetpartsRR((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR?s"   % # cCs |dk r|j|ndS(N(RR8(RR@((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRKs cCs0|jrtjddStt|j|S(Ns@send() called, but reseponse already received. Not sending data.(RR9R:RRR8(Rtstr((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR8s  cCsE|jdd}t|dkoD|djdoD|ddkS(NiiisHTTP/it100(RIRRLRM(RRRRS((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRJsN(RRt__doc__RR R%R4RRARER?RKR8RJ(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR4s    $ %  tAWSHTTPConnectioncBseZdZRS(s8 An HTTPConnection that supports 100 Continue behavior. (RRRV(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRWstAWSHTTPSConnectioncBseZdZRS(s9 An HTTPSConnection that supports 100 Continue behavior. (RRRV(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRXstAWSHTTPConnectionPoolcBseZeZRS((RRRWt ConnectionCls(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRYstAWSHTTPSConnectionPoolcBseZeZRS((RRRXRZ(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR[sc Cs|}|d k r)|d}||dConstructs a :class:`AWSPreparedRequest `.(RR|(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR|scCs7|jj}t|tjr3|jd}n|S(Nsutf-8(R|R(R+RR,R.(RR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR(sN( RRRVRuRRRRR|tpropertyR((((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRls  RzcBs)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'R)R(Ry(RR&R'R)R(Ry((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRs     cCs&d}||j|j|j|jfS(NsD(RyR&R'R)(Rtfmt((s4/usr/lib/fence-agents/bundled/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_typeR,t bytearrayR(RR+R9R:Rt ExceptionR (Rtnon_seekable_typeste((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt reset_streams !(RRRVRRR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRzs   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_codeRR)trawRt_content(RR'RR)R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR$s    cCs@|jdkr9tj|jjp0t|_n|jS(s!Content of the response as bytes.N(RRR7R/Rtstream(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pytcontent,s*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(RbRctget_encoding_from_headersR)RRN(Rtencoding((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyttext9s(RRRVRRRR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRs   t _HeaderKeycBs5eZdZdZdZdZdZRS(cCs||_|j|_dS(N(t_keytlowert_lower(RR((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRIs cCs t|jS(N(thashR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt__hash__MscCst|to|j|jkS(N(R+RR(Rtother((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt__eq__PscCs|jS(N(R(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt__str__SscCs t|jS(N(treprR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRVs(RRRRRRR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRHs     RcBsVeZdZdZdZdZdZdZdZdZ dZ RS( s:A case-insenseitive dictionary to represent HTTP headers. cOsi|_|j||dS(N(t_dicttupdate(RRR((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyR\s cCs||jt|js(R(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt__iter__iscCs t|jS(N(RLR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyt__len__lscCs t|jS(N(RR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRoscCst|jS(N(RR(R((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pytcopyrs( RRRVRRRRRRRR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyRZs       (,RtloggingRPt urllib3.utilR;turllib3.connectionRRturllib3.connectionpoolRRtbotocore.utilsRbtbotocore.compatRRRRRR R R tbotocore.exceptionsR t getLoggerRR9R tobjectRRWRXRYR[RRjRnRaRuRlRzRRR(((s4/usr/lib/fence-agents/bundled/botocore/awsrequest.pyts8     4 '  l921