U e @sUddlmZddlZddlZddlmZddlmZddlm Z ddl m Z ej r`dd lm Z d Zed d d gZdZz.z ddlZWnek rddlZYnXWnek rYn Xed7Zz ddlZWnek rYn Xed7ZGdddeZejZded<ejeefZddddddhZd5ddddddddd d!Z d"d#d#d$d%d&Z!d'd(d)d*d+d,Z"Gd-d.d.ej#Z$d/d0d1d.d2d3d4Z%dS)6) annotationsN) b64encode)Enum)UnrewindableBodyError)to_bytes)Finalz@@@SKIP_HEADER@@@accept-encodinghost user-agentz gzip,deflatez,brz,zstdc@seZdZdZdS)_TYPE_FAILEDTELLrN)__name__ __module__ __qualname__tokenrrB/opt/hc_python/lib/python3.8/site-packages/urllib3/util/request.pyr 'sr zFinal[_TYPE_FAILEDTELL] _FAILEDTELLGETHEADDELETETRACEOPTIONSCONNECTz bool | Nonezbool | list[str] | str | Nonez str | Nonezdict[str, str]) keep_aliveaccept_encoding user_agent basic_authproxy_basic_auth disable_cachereturncCsi}|r6t|trnt|tr*d|}nt}||d<|rB||d<|rNd|d<|rndt|d|d<|rdt|d|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)rrrrrr headersrrr make_headers7s2/   r-z typing.Anyz_TYPE_BODY_POSITION | None)bodyposr!cCsN|dk rt||n6t|dddk rJz |}Wntk rHt}YnX|S)z If a position is provided, move file to that point. Otherwise, we'll attempt to record a position for future use. Ntell) rewind_bodygetattrr0OSErrorr)r.r/rrrset_file_positions   r4ztyping.IO[typing.AnyStr]_TYPE_BODY_POSITIONNone)r.body_posr!c Cst|dd}|dk rZt|trZz ||Wqtk rV}ztd|W5d}~XYqXn&|tkrltdntdt|ddS)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 .)r2r%intr3rr ValueErrortype)r.r7 body_seekerrrr1s"  r1c@seZdZUded<ded<dS)ChunksAndContentLengthztyping.Iterable[bytes] | Nonechunksz int | Nonecontent_lengthN)rrr__annotations__rrrrr?s r?ztyping.Any | Noner&r:)r.method blocksizer!c sdkr$d}|tkrd}qd}ntttfrJtf}t|d}ntdrtddfdd }|}d}ndz t}WnJt k rzt }d}Wn$t k rt ddYnXYnXf}|j }t ||d S) 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. Nrreadztyping.Iterable[bytes])r!c3s6ttj}}|sq2|r*|d}|Vq dS)Nz iso-8859-1)r%io TextIOBaserEr*)r* datablockrDr.rrchunk_readables   z&body_to_chunks..chunk_readablezO'body' must be a bytes-like object, file-like object, or iterable. Instead was )r@rA) upper_METHODS_NOT_EXPECTING_BODYr%r&bytesrlenhasattr memoryview TypeErroriternbytesr?)r.rCrDr@rArJmvrrIrbody_to_chunkss6     rU)NNNNNN)& __future__rrFtypingbase64renumr exceptionsrutilr TYPE_CHECKINGr SKIP_HEADER frozensetSKIPPABLE_HEADERSr)Z brotlicffiZ_unused_module_brotli ImportErrorbrotliZ zstandardZ_unused_module_zstdr rrrBUnionr:r5rLr-r4r1 NamedTupler?rUrrrrsP        O