�
��^i�! � �� � d dl mZ d dlZd dlZd dlZddlmZ dd�Zd� Z dd d
�Z
e
� d� ed d� � D � � � � d
� Z
d� ZeZ G d� de� � ZdS )� )�absolute_importN� )�six�application/octet-streamc �B � | rt j | � � d p|S |S )z�
Guess the "Content-Type" of a file.
:param filename:
The filename to guess the "Content-Type" of using :mod:`mimetypes`.
:param default:
If no "Content-Type" can be guessed, default to `default`.
r )� mimetypes�
guess_type)�filename�defaults ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/urllib3/fields.py�guess_content_typer
s, � � � <��#�H�-�-�a�0�;�G�;��N� c �� �� t �t j � � r�� d� � �t �fd�dD � � � � s7| �d��d�} |� d� � |S # t t f$ r Y nw xY wt j r�� d� � �t j
� �d� � �| �d����t j r�� d� � ��S )a!
Helper function to format and quote a single header parameter using the
strategy defined in RFC 2231.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows
`RFC 2388 Section 4.4 `_.
:param name:
The name of the parameter, a string expected to be ASCII only.
:param value:
The value of the parameter, provided as ``bytes`` or `str``.
:ret:
An RFC-2231-formatted unicode string.
�utf-8c 3 � �K � | ]}|�v V � � d S �N� )�.0�ch�values �r � z.format_header_param_rfc2231..+ s' �� � � �/�/�r�r�U�{�/�/�/�/�/�/r z"\
�="�"�asciiz*=)�
isinstancer �binary_type�decode�any�encode�UnicodeEncodeError�UnicodeDecodeError�PY2�email�utils�encode_rfc2231)�namer �results ` r �format_header_param_rfc2231r( s
�� � �%���)�)� &����W�%�%���/�/�/�/�Y�/�/�/�/�/� �#�t�t�U�U�U�+�� ��M�M�'�"�"�"� �M�� #�$6�7� � � ��D� ����
�w� &����W�%�%��
�K�&�&�u�g�6�6�E����e�e�$�E�
�w� &����W�%�%���Ls �A, �,B �?B z%22z\\)r �\c �f � i | ].}|d v�t j |� � d� |� � ��/S ))� z%{:02X})r �unichr�format)r �ccs r �
r/ J sE � � � � ��
�W��� �
�2���
�)�)�"�-�-���r � c �� �� �fd�}t j d� d� �� � � D � � � � � � }|� || � � }|S )Nc �: �� �| � d� � S )Nr )�group)�match�needles_and_replacementss �r �replacerz#_replace_multiple..replacerS s �� �'����A���7�7r �|c �6 � g | ]}t j |� � ��S r )�re�escape)r �needles r �
z%_replace_multiple..W s" � �S�S�S��2�9�V�$�$�S�S�Sr )r9 �compile�join�keys�sub)r r5 r6 �patternr' s ` r �_replace_multiplerB R st �� �8� 8� 8� 8� 8� �j�� � �S�S�3K�3P�3P�3R�3R�S�S�S�T�T�� �G� �[�[��5�
)�
)�F��Mr c � � t |t j � � r|� d� � }t |t
� � }| �d|�d�S )a�
Helper function to format and quote a single header parameter using the
HTML5 strategy.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows the `HTML5 Working Draft
Section 4.10.22.7`_ and matches the behavior of curl and modern browsers.
.. _HTML5 Working Draft Section 4.10.22.7:
https://w3c.github.io/html/sec-forms.html#multipart-form-data
:param name:
The name of the parameter, a string expected to be ASCII only.
:param value:
The value of the parameter, provided as ``bytes`` or `str``.
:ret:
A unicode string, stripped of troublesome characters.
r r r )r r r r rB �_HTML5_REPLACEMENTS)r&