1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
U
M±d(.ã@s€ddlZddlmZddlmZmZddlmZmZm    Z    m
Z
m Z m Z ddl mZmZddlmZmZddlmZmZmZd    d
d d d ddgZe e d¡¡Ze e d¡¡ZGdd    „d    eƒZedddGdd
„d
eƒƒZedddGdd„deƒƒZedddGdd „d eƒƒZedddGdd „d eƒƒZ edddGdd „d eƒƒZ!edddGdd„deƒƒZ"eddGdd„deƒƒZ#dS)éN)ÚABC)Ú    dataclassÚfield)ÚAnyÚcastÚDictÚListÚTupleÚUnioné)ÚmethodÚrequest_target)ÚHeadersÚnormalize_and_validate)ÚbytesifyÚLocalProtocolErrorÚvalidateÚEventÚRequestÚInformationalResponseÚResponseÚDataÚ EndOfMessageÚConnectionClosedÚasciic@seZdZdZdZdS)rz$
    Base class for h11 events.
    ©N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__rrrúBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\h11/_events.pyr sFT)ÚinitÚfrozenc    sœeZdZUdZdZeed<eed<eed<eed<ddd    œeee    feee
e eefe
e e    e    ffeee    feee    fe d
d œ‡fd d „Z d
Z‡ZS)ranThe beginning of an HTTP request.
 
    Fields:
 
    .. attribute:: method
 
       An HTTP method, e.g. ``b"GET"`` or ``b"POST"``. Always a byte
       string. :term:`Bytes-like objects <bytes-like object>` and native
       strings containing only ascii characters will be automatically
       converted to byte strings.
 
    .. attribute:: target
 
       The target of an HTTP request, e.g. ``b"/index.html"``, or one of the
       more exotic formats described in `RFC 7320, section 5.3
       <https://tools.ietf.org/html/rfc7230#section-5.3>`_. Always a byte
       string. :term:`Bytes-like objects <bytes-like object>` and native
       strings containing only ascii characters will be automatically
       converted to byte strings.
 
    .. attribute:: headers
 
       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for details.
 
    .. attribute:: http_version
 
       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.
 
    )r ÚheadersÚtargetÚ http_versionr r$r%r&ó1.1F)r&Ú_parsedN)r r$r%r&r(Úreturnc    stƒ ¡t|tƒr$t |d|¡nt |dt||d¡|svt |dt|ƒ¡t |dt|ƒ¡t |dt|ƒ¡n*t |d|¡t |d|¡t |d|¡d}|jD]\}}|dkrª|d7}qª|j    d    krÞ|dkrÞt
d
ƒ‚|dkrît
d ƒ‚t t |j d ƒt t|jd ƒdS)Nr$©r(r r%r&rshostr r'zMissing mandatory Host: headerzFound multiple Host: headerszIllegal method characterszIllegal target characters)ÚsuperÚ__init__Ú
isinstancerÚobjectÚ __setattr__rrr$r&rrÚ    method_rer Úrequest_target_rer%)    Úselfr r$r%r&r(Z
host_countÚnameÚvalue©Ú    __class__rr!r,Rs2    
 
 
ÿ
zRequest.__init__)rrrrr ÚbytesÚ__annotations__rr
Ústrrr    Úboolr,Ú__hash__Ú __classcell__rrr5r!r(s"
!ù
$
 
ø+cs eZdZUdZeed<eed<eed<eed<dddd    œeee    e
eefe    e
e e ffeeee feee fe d
d œ‡fd d „Z d
dœdd„Zd
Z‡ZS)Ú _ResponseBase)r$r&ÚreasonÚ status_coder$r&r>r?r'óF)r&r>r(N)r$r?r&r>r(r)cs¾tƒ ¡t|tƒr$t |d|¡nt |dt||d¡|sˆt |dt|ƒ¡t |dt|ƒ¡t|tƒstt    dƒ‚t |dt|ƒ¡n*t |d|¡t |d|¡t |d|¡| 
¡dS)Nr$r*r>r&zstatus code must be integerr?) r+r,r-rr.r/rrÚintrÚ __post_init__)r2r$r?r&r>r(r5rr!r,‰s$    
 
 
ÿ
z_ResponseBase.__init__©r)cCsdS)Nr©r2rrr!rB¨sz_ResponseBase.__post_init__)rrrr rr8r7rAr
rr    r9r:r,rBr;r<rrr5r!r=€s$
ù$
 
ør=c@s"eZdZdZddœdd„ZdZdS)raAn HTTP informational response.
 
    Fields:
 
    .. attribute:: status_code
 
       The status code of this response, as an integer. For an
       :class:`InformationalResponse`, this is always in the range [100,
       200).
 
    .. attribute:: headers
 
       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for
       details.
 
    .. attribute:: http_version
 
       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.
 
    .. attribute:: reason
 
       The reason phrase of this response, as a byte string. For example:
       ``b"OK"``, or ``b"Not Found"``.
 
    NrCcCs,d|jkrdks(ntd |j¡ƒ‚dS)NédéÈzGInformationalResponse status_code should be in range [100, 200), not {}©r?rÚformatrDrrr!rBÎs ÿÿz#InformationalResponse.__post_init__©rrrrrBr;rrrr!r¯sc@s"eZdZdZddœdd„ZdZdS)rañThe beginning of an HTTP response.
 
    Fields:
 
    .. attribute:: status_code
 
       The status code of this response, as an integer. For an
       :class:`Response`, this is always in the range [200,
       1000).
 
    .. attribute:: headers
 
       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for details.
 
    .. attribute:: http_version
 
       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.
 
    .. attribute:: reason
 
       The reason phrase of this response, as a byte string. For example:
       ``b"OK"``, or ``b"Not Found"``.
 
    NrCcCs,d|jkrdks(ntd |j¡ƒ‚dS)NrFièz;Response status_code should be in range [200, 1000), not {}rGrDrrr!rB÷s ÿÿzResponse.__post_init__rIrrrr!rÙs    c@sHeZdZUdZdZeed<eed<eed<d eeeddœd    d
„ZdZ    dS) raPart of an HTTP message body.
 
    Fields:
 
    .. attribute:: data
 
       A :term:`bytes-like object` containing part of a message body. Or, if
       using the ``combine=False`` argument to :meth:`Connection.send`, then
       any object that your socket writing code knows what to do with, and for
       which calling :func:`len` returns the number of bytes that will be
       written -- see :ref:`sendfile` for details.
 
    .. attribute:: chunk_start
 
       A marker that indicates whether this data object is from the start of a
       chunked transfer encoding chunk. This field is ignored when when a Data
       event is provided to :meth:`Connection.send`: it is only valid on
       events emitted from :meth:`Connection.next_event`. You probably
       shouldn't use this attribute at all; see
       :ref:`chunk-delimiters-are-bad` for details.
 
    .. attribute:: chunk_end
 
       A marker that indicates whether this data object is the last for a
       given chunked transfer encoding chunk. This field is ignored when when
       a Data event is provided to :meth:`Connection.send`: it is only valid
       on events emitted from :meth:`Connection.next_event`. You probably
       shouldn't use this attribute at all; see
       :ref:`chunk-delimiters-are-bad` for details.
 
    )ÚdataÚ chunk_startÚ    chunk_endrJrKrLFN)rJrKrLr)cCs.t |d|¡t |d|¡t |d|¡dS)NrJrKrL)r.r/)r2rJrKrLrrr!r,+sz Data.__init__)FF)
rrrrr r7r8r:r,r;rrrr!rs
 ÿþ csheZdZUdZdZeed<dddœeeee    e
e
fee    e e fdfe ddœ‡fdd    „Z dZ‡ZS)
rajThe end of an HTTP message.
 
    Fields:
 
    .. attribute:: headers
 
       Default value: ``[]``
 
       Any trailing headers attached to this message, represented as a list of
       (name, value) pairs. See :ref:`the header normalization rules
       <headers-format>` for details.
 
       Must be empty unless ``Transfer-Encoding: chunked`` is in use.
 
    )r$r$NF)r$r()r$r(r)csDtƒ ¡|dkrtgƒ}nt|tƒs2t||d}t |d|¡dS)Nr*r$)r+r,rr-rr.r/)r2r$r(r5rr!r,Qs 
 
 
 zEndOfMessage.__init__)rrrrr rr8r
rr    r7r9r:r,r;r<rrr5r!r;s
ú"ÿù)r#c@seZdZdZdS)raAThis event indicates that the sender has closed their outgoing
    connection.
 
    Note that this does not necessarily mean that they can't *receive* further
    data, because TCP connections are composed to two one-way channels which
    can be closed independently. See :ref:`closing` for details.
 
    No fields.
    N)rrrrrrrr!res
)$ÚreÚabcrZ dataclassesrrÚtypingrrrrr    r
Z_abnfr r Ú_headersrrZ_utilrrrÚ__all__ÚcompileÚencoder0r1rrr=rrrrrrrrr!Ú<module>s>  ù
 
W
.
)
)
7
)