← Back
Editing: http.cpython-311.pyc
� �|�e$E � � � d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dl m Z d dlmZm Z mZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlm Z e d ej! � � Z"d �# � � Z$dZ%dZ&d Z'dZ(dZ)dZ* e de%�de'�de(�de*�d� � � Z+ e de%�de'�de)�de*�d� � � Z, e de'�de&�de*�de(�d� � � Z-dZ.dZ/ed7d�� � Z0ed8d�� � Z1ed� � � Z2ed� � � Z3d9d!�Zd:d"�Z4d#� Z5d$� Z6d%� Z7d&� Z8d'� Z9d(� Z:d)� Z;d*� Z<d+� Z=d9d,�Z>d9d-�Z?d;d/�Z@d;d0�ZAd9d1�ZB d<d5�ZCd6� ZDdS )=� N)�Error�� formatdate)�ParseResult�SplitResult�_coerce_args�_splitnetloc�_splitparams�quote� quote_plus�scheme_chars�unquote�unquote_plus� urlencode�uses_params)�MultiValueDict)�RemovedInDjango40Warning)�keep_lazy_text)�_lazy_re_compilez� \A( # start of string and capture group (?:W/)? # optional weak indicator " # opening quote [^"]* # any sequence of non-quote characters " # end quote )\Z # end of string and capture group z/jan feb mar apr may jun jul aug sep oct nov decz(?P<day>\d{2})z(?P<day>[ \d]\d)z(?P<mon>\w{3})z(?P<year>\d{4})z(?P<year>\d{2})z-(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})z^\w{3}, � z GMT$z ^\w{6,9}, �-z^\w{3} �$z:/?#[]@z!$&'()*+,;=�/c �Z � t j dt d�� � t | |� � S )z� A legacy compatibility wrapper to Python's urllib.parse.quote() function. (was used for unicode handling on Python 2) zLdjango.utils.http.urlquote() is deprecated in favor of urllib.parse.quote().� �� stacklevel)�warnings�warnr r ��url�safes �3/usr/lib/python3/dist-packages/django/utils/http.py�urlquoter$ - s9 � � �M� � �Q�� � � � ��d���� � c �Z � t j dt d�� � t | |� � S )z� A legacy compatibility wrapper to Python's urllib.parse.quote_plus() function. (was used for unicode handling on Python 2) zVdjango.utils.http.urlquote_plus() is deprecated in favor of urllib.parse.quote_plus(),r r )r r r r r s r# � urlquote_plusr( ; s9 � � �M� %� �Q�� � � � �c�4� � � r% c �X � t j dt d�� � t | � � S )z� A legacy compatibility wrapper to Python's urllib.parse.unquote() function. (was used for unicode handling on Python 2) zPdjango.utils.http.urlunquote() is deprecated in favor of urllib.parse.unquote().r r )r r r r �� quoted_urls r# � urlunquoter, I s7 � � �M� "� �Q�� � � � �:���r% c �X � t j dt d�� � t | � � S )z� A legacy compatibility wrapper to Python's urllib.parse.unquote_plus() function. (was used for unicode handling on Python 2) zZdjango.utils.http.urlunquote_plus() is deprecated in favor of urllib.parse.unquote_plus().r r )r r r r r* s r# �urlunquote_plusr. W s7 � � �M� '� �Q�� � � � � �#�#�#r% Fc �X � t | t � � r| � � � } n$t | d� � r| � � � } g }| D ]�\ }}|�t d|z � � �|rt |t t f� � r|}nw t |� � }g }|D ]O}|�t d|z � � �t |t � � st |� � }|� |� � �Pn# t $ r |}Y nw xY w|� ||f� � ��t ||� � S )z A version of Python's urllib.parse.urlencode() function that can operate on MultiValueDict and non-string values. �itemsNzjCannot encode None for key '%s' in a query string. Did you mean to pass an empty string or omit the value?)� isinstancer �lists�hasattrr0 � TypeError�str�bytes�iter�append�original_urlencode)�query�doseq�query_params�key�value� query_val�itr�items r# r r e s� � � �%��(�(� ���� � ��� ��� � � ���� � ���L�� .� .� ��U��=��B�DG�H�� � � � +�*�U�S�%�L�9�9� +��I�I� +��5�k�k�� � �� +� +�D��|�'�.�03�4�� � � (��e�4�4� )�"�4�y�y���$�$�T�*�*�*�*� +�� � "� "� "�!� � � � "���� ���S�)�,�-�-�-�-��l�E�2�2�2s �C2�2D� Dc �$ � t | d�� � S )ao Format the time to match the RFC1123 date format as specified by HTTP RFC7231 section 7.1.1.1. `epoch_seconds` is a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, it defaults to the current time. Output a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. T)�usegmtr )� epoch_secondss r# � http_daterE � s � � �m�D�1�1�1�1r% c �" � t t t fD ]}|� | � � }|� n�t d| z � � � t |d � � }|dk rEt j � � � j }||dz z }||dz z dk r ||dz z }n||z }t � |d � � � � � dz }t |d � � }t |d � � }t |d � � } t |d � � } t j ||||| | � � }t j |� � � � � S # t $ r}t d| z � � |�d}~ww xY w) a Parse a date format as specified by HTTP RFC7231 section 7.1.1.1. The three formats allowed by the RFC are accepted, even if only the first one is still in widespread use. Return an integer expressed in seconds since the epoch, in UTC. Nz%%r is not in a valid HTTP date format�year�d �2 �mon� �day�hour�min�secz%r is not a valid date)�RFC1123_DATE�RFC850_DATE�ASCTIME_DATE�match� ValueError�int�datetime�utcnowrG �MONTHS�index�lower�calendar�timegm�utctimetuple� Exception) �date�regex�mrG �current_year�current_century�monthrL rM rN rO �result�excs r# �parse_http_daterg � s� � � �{�L�8� I� I���K�K������=��E� � �@�4�G�H�H�H�C��1�V�9�~�~���#�:�:�#�,�3�3�5�5�:�L�*�l�S�.@�A�O��|�c�)�*�R�/�/� ��#�-�-�����'�����Q�u�X�^�^�-�-�.�.��2���!�E�(�m�m���1�V�9�~�~���!�E�(�m�m���!�E�(�m�m���"�4���T�3��D�D����v�2�2�4�4�5�5�5��� C� C� C��1�D�8�9�9�s�B�����C���s �D'E, �, F�6F � Fc �D � t | � � S # t $ r Y dS w xY w)zK Same as parse_http_date, but return None if the input is invalid. N)rg r^ )r_ s r# �parse_http_date_saferi � s7 � � ��t�$�$�$��� � � ���� ���s � � �c �f � t | � � dk rt d� � �t | d� � S )zf Convert a base 36 string to an int. Raise ValueError if the input won't fit into an int. � zBase36 input too large�$ )�lenrT rU ��ss r# � base36_to_intrp � s0 � � �1�v�v��{�{��1�2�2�2��q�"�:�:�r% c � � d}| dk rt d� � �| dk r|| S d}| dk r$t | d� � \ } }|| |z }| dk �$|S )z&Convert an integer to a base36 string.�$0123456789abcdefghijklmnopqrstuvwxyzr z!Negative base36 conversion input.rl r&