U f|1 @ s d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl Zd dl ZddlmZ ddl mZ ddlmZmZ ddlmZ ddlmZ eZed ZeeZed ZedZdd dddZdd dddZ G dd dej!e Z"G dd deZ#G dd deZ$dS ) )annotationsN ) _TYPE_BODY)HTTPHeaderDict)HTTPSConnection_get_default_user_agent)ConnectionError)BaseHTTPResponseTs ^[!#$%&'*+\-.^_`|~0-9a-z]+$s* [\0\x00\x0a\x0d\r\n]|^[ \r\n\t]|[ \r\n\t]$bytesbool)namereturnc C s t t| S )a5 "An implementation that validates fields according to the definitions in Sections 5.1 and 5.5 of [HTTP] only needs an additional check that field names do not include uppercase characters." (https://httpwg.org/specs/rfc9113.html#n-field-validity) `http.client._is_legal_header_name` does not validate the field name according to the HTTP 1.1 spec, so we do that here, in addition to checking for uppercase characters. This does not allow for the `:` character in the header name, so should not be used to validate pseudo-headers. )r RE_IS_LEGAL_HEADER_NAMEmatch)r r I/opt/alt/python38/lib/python3.8/site-packages/urllib3/http2/connection.py_is_legal_header_name s r )valuer c C s t t| S )aK "A field value MUST NOT contain the zero value (ASCII NUL, 0x00), line feed (ASCII LF, 0x0a), or carriage return (ASCII CR, 0x0d) at any position. A field value MUST NOT start or end with an ASCII whitespace character (ASCII SP or HTAB, 0x20 or 0x09)." (https://httpwg.org/specs/rfc9113.html#n-field-validity) )r RE_IS_ILLEGAL_HEADER_VALUEsearch)r r r r _is_illegal_header_value, s r c @ sD e Zd ZdZdZddddZdddd Zd ddd dddZdS ) _LockedObjectaX A wrapper class that hides a specific object behind a lock. The goal here is to provide a simple way to protect access to an object that cannot safely be simultaneously accessed from multiple threads. The intended use of this class is simple: take hold of it with a context manager, which returns the protected object. )lock_objr )objc C s t | _|| _d S N) threadingRLockr r )selfr r r r __init__D s z_LockedObject.__init__r c C s | j | jS r )r acquirer r r r r __enter__H s z_LockedObject.__enter__ztype[BaseException] | NonezBaseException | Noneztypes.TracebackType | NoneNone)exc_typeexc_valexc_tbr c C s | j d S r )r release)r r&