관리-도구
편집 파일: filepost.cpython-38.pyc
U )�e[ � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlmZ ddlm Z m Z e�d�d Zej ejejee f e f Zejeejee f f Zdd �d d�Zdd d�dd�Zddddd�dd�ZdS )� )�annotationsN)�BytesIO� )�_TYPE_FIELD_VALUE_TUPLE�RequestFieldzutf-8� �str)�returnc C s t �t�d���� S )zN Our embarrassingly-simple replacement for mimetools.choose_boundary. � )�binascii�hexlify�os�urandom�decode� r r �>/opt/hc_python/lib/python3.8/site-packages/urllib3/filepost.py�choose_boundary s r �_TYPE_FIELDSztyping.Iterable[RequestField])�fieldsr c c sF t | tj�r| �� }n| }|D ]"}t |t�r4|V qtj|� V qdS )z� Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`. N)� isinstance�typing�Mapping�itemsr �from_tuples)r �iterable�fieldr r r �iter_field_objects s r z str | Noneztuple[bytes, str])r �boundaryr c C s� t � }|dkrt� }t| �D ]t}|�d|� d��d�� t|��|�� � |j}t|t �rbt |�}t|t �r|t|��|� n |�|� |�d� q|�d|� d��d�� d|� �}|�� |fS )a� Encode a dictionary of ``fields`` using the multipart/form-data MIME format. :param fields: Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). Values are processed by :func:`urllib3.fields.RequestField.from_tuples`. :param boundary: If not specified, then a random boundary will be generated using :func:`urllib3.filepost.choose_boundary`. Nz--z zlatin-1s z-- zmultipart/form-data; boundary=)r r r �write�encode�writer�render_headers�datar �intr �getvalue)r r �bodyr r"