�
�g.
� �P � d dl mZ d dlmZ d dlmZmZ ddlm Z d d�Z
d
d�Zdd�Zy)� )�annotationsN)�!MultipartInvariantViolationDefect�StartBoundaryNotFoundDefect� )�HeaderParsingErrorc �� � | j � S # t $ r Y nw xY w | j S # t $ r Y nw xY w | j du S # t $ r
Y t d� �w xY w)zt
Checks whether a given file-like object is closed.
:param obj:
The file-like object to check.
Nz)Unable to determine whether fp is closed.)�isclosed�AttributeError�closed�fp�
ValueError)�objs �7/usr/lib/python3/dist-packages/urllib3/util/response.py�is_fp_closedr s{ � �
� �|�|�~����
��
��
��z�z����
��
��
� �v�v��~����
��
�@�
A�A�
�s) � � ��. � :�:�
A � A"�!A"c �f � t | t j � st dt | � � d�� �d}| j � s(| j
� }t |t t f� r|}| j D �cg c] }t |t t f� s|�� }}|s|r
t ||�� �yc c}w )a>
Asserts whether all headers have been successfully parsed.
Extracts encountered errors from the result of parsing headers.
Only works on Python 3.
:param http.client.HTTPMessage headers: Headers to verify.
:raises urllib3.exceptions.HeaderParsingError:
If parsing errors are found.
zexpected httplib.Message, got �.N)�defects�
unparsed_data)
�
isinstance�httplib�HTTPMessage� TypeError�type�is_multipart�get_payload�bytes�strr r r r )�headersr �payload�defectr s r �assert_header_parsingr! ( s� � � �g�w�2�2�3��8��g���q�I�J�J��M� ���!��%�%�'���g��s�|�,�#�M� �o�o�����0�2S�T�
� ��G� � �-� ��
�N�N� ��s �;B.c �@ � | j }|j � dk( S )z�
Checks whether the request of a response has been a HEAD-request.
:param http.client.HTTPResponse response:
Response to check if the originating request
used 'HEAD' as a method.
�HEAD)�_method�upper)�response�
method_strs r �is_response_to_headr( [ s# � � �!�!�J������'�'� )r �object�return�bool)r zhttplib.HTTPMessager+ �None)r& |