ó ÞtÚ_c@sddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl Z ddlmZddlmZmZmZmZmZmZddlmZejeƒZd efd „ƒYZd efd „ƒYZd eefd„ƒYZdeefd„ƒYZde fd„ƒYZ de fd„ƒYZ!ddd„Z#d„Z$d„Z%defd„ƒYZ&defd„ƒYZ'defd„ƒYZ(defd„ƒYZ)d efd!„ƒYZ*d"efd#„ƒYZ+dS($iÿÿÿÿN(tVerifiedHTTPSConnection(tHTTPConnection(tHTTPConnectionPool(tHTTPSConnectionPool(tsix(t HTTPHeaderst HTTPResponset urlunsplitturlsplitt urlencodetMutableMapping(tUnseekableStreamErrortAWSHTTPResponsecBseZd„Zd„ZRS(cOs)|jdƒ|_tj|||ŽdS(Nt status_tuple(tpopt _status_tupleRt__init__(tselftargstkwargs((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR&scCs6|jdk r%|j}d|_|Stj|ƒSdS(N(RtNoneRt _read_status(RR ((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR*s   (t__name__t __module__RR(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR #s t AWSConnectioncBskeZdZd„Zd„Zd„Zd„Zd d„Zd„Z d„Z d„Z d „Z d „Z RS( süMixin 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((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR?s cCs5tt|ƒjƒt|_t|_|j|_dS(N(RRtcloseRRRRR(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRMs  cOsvt|_|jddƒdkr-t|_nt|_|j|_tt|ƒj ||||||Ž}t|_|S(NtExpectts 100-continue( RRtgettTrueRRRRRt _send_request(RtmethodturltbodytheadersRRtrval((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR$Ts     cCsbg}xF|D]>}t|tjƒr>|j|jdƒƒq |j|ƒq Wdj|ƒ}|S(Nsutf-8s (t isinstanceRt text_typetappendtencodetjoin(Rt mixed_buffert bytes_buffertchunktmsg((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt_convert_to_bytes`s cOsÇ|jjdƒ|j|jƒ}|j2t|tƒrK||7}d}n|j|ƒ|jr§tj dƒt j j |j dƒr—|j|ƒdStj dƒn|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_buffertextendR3R*tbytesRtsendRtloggertdebugturllib3tutilt wait_for_readtsockt_handle_expect_response(Rt message_bodyRRR2((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt _send_outputms        cCs)d}x|dkr$|jƒ}q WdS(Ns (Rtreadline(Rtfptcurrent((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt_consume_headers‘scCs|jjddƒ}zê|jƒ}|jddƒ}|j|ƒro|j|ƒtjdƒ|j |ƒnt |ƒdkrþ|dj dƒrþtjdƒ|dj dƒt |d ƒ|dj dƒf}tjtd |ƒ}||_t|_nWd|jƒXdS( Ntrbiis5100 Continue response seen, now sending request body.isHTTP/sOReceived a non 100 Continue response from the server, NOT sending request body.tasciiiR (R=tmakefileRAtsplitRt_is_100_continue_statusRDR8R9t_send_message_bodytlent startswithtdecodetintt functoolstpartialR RR#RR(RR?RBtmaybe_status_linetpartsR R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR>s"   % # cCs |dk r|j|ƒndS(N(RR7(RR?((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRJÂs cCs0|jrtjdƒdStt|ƒj|ƒS(Ns@send() called, but reseponse already received. Not sending data.(RR8R9RRR7(Rtstr((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR7Æs  cCsE|jddƒ}t|ƒdkoD|djdƒoD|ddkS(NiiisHTTP/it100(RHRRKRL(RRQRR((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRIÍs%N(RRt__doc__RRR$R3RR@RDR>RJR7RI(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR3s    $ %  tAWSHTTPConnectioncBseZdZRS(s8 An HTTPConnection that supports 100 Continue behavior. (RRRU(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRVÕstAWSHTTPSConnectioncBseZdZRS(s9 An HTTPSConnection that supports 100 Continue behavior. (RRRU(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRWÙstAWSHTTPConnectionPoolcBseZeZRS((RRRVt ConnectionCls(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRXÝstAWSHTTPSConnectionPoolcBseZeZRS((RRRWRY(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRZásc CsÓ|}|d k r)|d}||d/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pytprepare_request_dictås          c CsH|}td|dd|dd|dd|dƒ}|d|_|S(sK This method takes a request dict and creates an AWSRequest object from it. :type request_dict: dict :param request_dict: The request dict (created from the ``prepare_request_dict`` method). :rtype: ``botocore.awsrequest.AWSRequest`` :return: An AWSRequest object based on the request_dict. R%R&tdataR'R(R_(t AWSRequestR_(RdRgtrequest_object((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pytcreate_request_object s + cCsÒt|ƒ}| s|dkr?|ds2d}q„|d}nE|djdƒrv|jdƒrv|dd |}n|d|}|d}|dk r§||}nt|d|||d|dfƒ}|S(Nt/iiÿÿÿÿiiii(RtendswithRLRR(ReR\R[tptnew_patht new_netloct reconstructed((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR`!s    "   'tAWSRequestPreparercBsGeZdZd„Zd„Zdd„Zd„Zd„Zd„Z RS(s  This class performs preparation on AWSRequest objects similar to that of the PreparedRequest class does in the requests library. However, the logic has been boiled down to meet the specific use cases in botocore. Of note there are the following differences: This class does not heavily prepare the URL. Requests performed many validations and corrections to ensure the URL is properly formatted. Botocore either performs these validations elsewhere or otherwise consistently provides well formatted URLs. This class does not heavily prepare the body. Body preperation is simple and supports only the cases that we document: bytes and file-like objects to determine the content-length. This will also additionally prepare a body that is a dict to be url encoded params string as some signers rely on this. Finally, this class does not support multipart file uploads. This class does not prepare the method, auth or cookies. cCsX|j}|j|ƒ}|j|ƒ}|j||ƒ}|j}t|||||ƒS(N(R%t _prepare_urlt _prepare_bodyt_prepare_headerst stream_outputtAWSPreparedRequest(RtoriginalR%R&R'R(Rx((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pytprepareQs   cCsJ|j}|jrFtt|jjƒƒdtƒ}d||f}n|S(Ntdoseqs%s?%s(R&tparamsR tlisttitemsR#(RRzR&R}((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRuZs   !cCs›t|jjƒƒ}d|ks-d|kr1|S|jdkr—|j|ƒ}|dk rnt|ƒ|d/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRwas   cCs^|\}}t|tjƒr0|jdƒ}nt|tjƒrT|jdƒ}n||fS(Nsutf-8(R*RR+R-(Rtitemtkeytvalue((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt_to_utf8vs  cCsn|j}|dkrd}nt|tƒrjg|jƒD]}|j|ƒ^q:}t|dtƒ}n|S(s"Prepares the given HTTP body data.R!R|N(RjRR*tdictRRR R#(RRzR'RŠR}((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRv~s   (cCs“|s dSyt|ƒSWnttfk r3}nXt|dƒrt|dƒr|jƒ}|jddƒ|jƒ}|j|ƒ||SdS(Nitseekttelli(RKtAttributeErrort TypeErrorthasattrRRR(RR'tetorig_post end_file_pos((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR…Šs   N( RRRUR{RuRRwRRvR…(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRt=s    RkcBsJeZdZeZdddddded„Zd„Ze d„ƒZ RS(s Represents the elements of an HTTP request. This class was originally inspired by requests.models.Request, but has been boiled down to meet the specific use cases in botocore. That being said this class (even in requests) is effectively a named-tuple. c Cs¯|jƒ|_|dkr!in|}||_||_tƒ|_||_||_||_ ||_ |dk r¢x*|j ƒD]\}} | |j|/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR«s          cCs|jj|ƒS(s>Constructs a :class:`AWSPreparedRequest `.(R˜R{(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR{ÎscCs7|jƒj}t|tjƒr3|jdƒ}n|S(Nsutf-8(R{R'R*RR+R-(RR'((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR'ÒsN( RRRURtR—RRRR{tpropertyR'(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRk¡s  RycBs)eZdZd„Zd„Zd„ZRS(s›A 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'Rx(RR%R&R(R'Rx((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRæs     cCs&d}||j|j|j|jfS(NsD(RxR%R&R((Rtfmt((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__repr__íscCstjtjtf}|jdks6t|j|ƒr:dSy'tjd|jƒ|jj dƒWn5t k r˜}tjd|ƒt d|jƒ‚nXdS(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*R8R9Rt ExceptionR (Rtnon_seekable_typesR”((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt reset_streamôs !(RRRURRœR¢(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRyÚs   t AWSResponsecBs5eZdZd„Zed„ƒZed„ƒZRS(s§A 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_codeR„R(trawRt_content(RR&R¤R(R¥((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRs    cCs@|jdkr9tƒj|jjƒƒp0tƒ|_n|jS(s!Content of the response as bytes.N(R¦RR6R.R¥tstream(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pytcontent!s*cCs?tjj|jƒ}|r+|jj|ƒS|jjdƒSdS(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(RaRbtget_encoding_from_headersR(R¨RM(Rtencoding((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyttext.s(RRRURRšR¨R«(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR£ s   t _HeaderKeycBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs||_|jƒ|_dS(N(t_keytlowert_lower(RR‹((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR>s cCs t|jƒS(N(thashR¯(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__hash__BscCst|tƒo|j|jkS(N(R*R¬R¯(Rtother((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__eq__EscCs|jS(N(R­(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__str__HscCs t|jƒS(N(treprR­(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRœKs(RRRR±R³R´Rœ(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR¬=s     R„cBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s:A case-insenseitive dictionary to represent HTTP headers. cOsi|_|j||ŽdS(N(t_dicttupdate(RRR((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRQs cCs||jt|ƒ/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt __setitem__UscCs|jt|ƒS(N(R¶R¬(RR‹((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt __getitem__XscCs|jt|ƒ=dS(N(R¶R¬(RR‹((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt __delitem__[scCsd„|jDƒS(Ncss|]}t|ƒVqdS(N(RS(t.0R‹((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pys _s(R¶(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__iter__^scCs t|jƒS(N(RKR¶(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyt__len__ascCs t|jƒS(N(RµR¶(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyRœdscCst|jƒƒS(N(R„R(R((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pytcopygs( RRRURR¸R¹RºR¼R½RœR¾(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyR„Os       (,tsystloggingROtsockett urllib3.utilR:turllib3.connectionRRturllib3.connectionpoolRRtbotocore.utilsRatbotocore.compatRRRRRR R tbotocore.exceptionsR t getLoggerRR8R tobjectRRVRWRXRZRRiRmR`RtRkRyR£R¬R„(((s>/opt/awscli/lib/python2.7/site-packages/botocore/awsrequest.pyts:      .¢ '  d921