CYhUddlmZddlZddlZddlmZddlmZddlm Z ddl m Z ejrdd l mZd Zegd Zd Z ddlZed z Z ddlZedz ZGddeZej4Zded<ej:eefZhdZ d ddZ! ddZ"ddZ#GddejHZ% ddZ&y#e$rddlZYwxYw#e$rYwxYw#e$rYwxYw)) annotationsN) b64encode)Enum)UnrewindableBodyError)to_bytes)Finalz@@@SKIP_HEADER@@@)accept-encodinghost user-agentz gzip,deflatez,brz,zstdceZdZdZy)_TYPE_FAILEDTELLrN)__name__ __module__ __qualname__token6/usr/lib/python3/dist-packages/urllib3/util/request.pyrr's ErrzFinal[_TYPE_FAILEDTELL] _FAILEDTELL>GETHEADTRACEDELETECONNECTOPTIONScti}|r>t|trn(t|trdj|}nt}||d<|r||d<|rd|d<|r.dt |j dj|d<|r.dt |j dj|d <|rd |d <|S) a Shortcuts for generating request headers. :param keep_alive: If ``True``, adds 'connection: keep-alive' header. :param accept_encoding: Can be a boolean, list, or string. ``True`` translates to 'gzip,deflate'. If either the ``brotli`` or ``brotlicffi`` package is installed 'gzip,deflate,br' is used instead. List will get joined by comma. String will be used as provided. :param user_agent: String representing the user-agent you want, such as "python-urllib3/0.6" :param basic_auth: Colon-separated username:password string for 'authorization: basic ...' auth header. :param proxy_basic_auth: Colon-separated username:password string for 'proxy-authorization: basic ...' auth header. :param disable_cache: If ``True``, adds 'cache-control: no-cache' header. Example: .. code-block:: python import urllib3 print(urllib3.util.make_headers(keep_alive=True, user_agent="Batman/1.0")) # {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'} print(urllib3.util.make_headers(accept_encoding=True)) # {'accept-encoding': 'gzip,deflate'} ,r r z keep-alive connectionzBasic zlatin-1 authorizationzproxy-authorizationzno-cachez cache-control) isinstancestrlistjoinACCEPT_ENCODINGrencodedecode) keep_aliveaccept_encoding user_agent basic_authproxy_basic_auth disable_cacheheaderss r make_headersr07s^!G os +   .!hh7O-O%4!" *  , Yz00;<CCEF G   Y/66yABIIKL M  ! #- Nrc|t|||St|dd |j}|S|S#t$r t}Y|SwxYw)z If a position is provided, move file to that point. Otherwise, we'll attempt to record a position for future use. Ntell) rewind_bodygetattrr2OSErrorr)bodyposs rset_file_positionr8sc D# J vt $ 0 ))+C J3J  C J  s3AAct|dd}|t|tr ||y|t ur t dt dt|d#t$r}t d|d}~wwxYw)z Attempt to rewind body to a certain position. Primarily used for request redirects and retries. :param body: File-like object that supports seek. :param int pos: Position to seek to in file. seekNzAAn error occurred when rewinding request body for redirect/retry.zRUnable to record file position for rewinding request body during a redirect/retry.z1body_pos must be of type integer, instead it was .)r4r"intr5rr ValueErrortype)r6body_pos body_seekes rr3r3sfd+IHc!:  h  [ # 4  ?X?Oq Q   'S  sA A/ A**A/c"eZdZUded<ded<y)ChunksAndContentLengthztyping.Iterable[bytes] | Nonechunksz int | Nonecontent_lengthN)rrr__annotations__rrrrCrCs ))rrCcd}|jtvrd}nld}nitttfrt f}t |d}n8tdrdfd }|}d}n t}f}|j}t||S#t$r. t}d}n#t$rtddwxYwYCwxYw)aRTakes the HTTP request method, body, and blocksize and transforms them into an iterable of chunks to pass to socket.sendall() and an optional 'Content-Length' header. A 'Content-Length' of 'None' indicates the length of the body can't be determined so should use 'Transfer-Encoding: chunked' for framing instead. Nrreadc3Kttj} j}|sy|r|j d}|,w)Nz iso-8859-1)r"io TextIOBaserHr')r' datablock blocksizer6s rchunk_readablez&body_to_chunks..chunk_readablesKbmm4F IIi0   ) 0 0 >I sAA zO'body' must be a bytes-like object, file-like object, or iterable. Instead was )rDrE)returnztyping.Iterable[bytes]) upper_METHODS_NOT_EXPECTING_BODYr"r#bytesr lenhasattr memoryviewnbytes TypeErroriterrC)r6methodrMrDrErNmvs` ` rbody_to_chunksr[s$ | <<>!< <N!N D3, '4."VAY v   ! 'D!BWFYYN ! OO  d!% 88rts" . ' " GH /2 uO+wOt(8'='= $=ll3(8#89W#59!!#'!% LL2LL L ! L  LL^ 5( <V.. CP CP%(CP58CPCPI /./    s< CC0 C"C%!C""C%%C-,C-0C87C8