*j t S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK r SSK
rSSKJ
r
/ SQrSrSrSrSrS rS
r\" 5 R- \R. R0 5 \R. R0 R3 5 V s0 s H o U R4 _M sn rSrSrS
r\R> " S5 R@ r!\R> " S5 RD r#\R> " S5 r$\R> " S5 r%1 Skr&S?S jr'S\(S\(4S jr) " S S\RT RV 5 r,S r-\,4S jr.\,4S jr/ " S S\R` 5 r1S r2 " S S 5 r3 SSK4r4 " S! S"\35 r5\Rm S"5 " S# S$\85 r9 " S% S&\95 r: " S' S(\95 r; " S) S*\95 r< " S+ S,\95 r= " S- S.\95 r> " S/ S0\95 r? " S1 S2\95 r@ " S3 S4\@5 rA " S5 S6\@5 rB " S7 S8\@5 rC " S9 S:\95 rD " S; S<\95 rE " S= S>\F\D5 rG\9rHgs sn f ! \7 a Nf = f)@a
HTTP/1.1 client library
HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:
(null)
|
| HTTPConnection()
v
Idle
|
| putrequest()
v
Request-started
|
| ( putheader() )* endheaders()
v
Request-sent
|\_____________________________
| | getresponse() raises
| response = getresponse() | ConnectionError
v v
Unread-response Idle
[Response-headers-read]
|\____________________
| |
| response.read() | putrequest()
v v
Idle Req-started-unread-response
______/|
/ |
response.read() | | ( putheader() )* endheaders()
v v
Request-started Req-sent-unread-response
|
| response.read()
v
Request-sent
This diagram presents the following rules:
-- a second request may not be started until {response-headers-read}
-- a response [object] cannot be retrieved until {request-sent}
-- there is no differentiation between an unread response body and a
partially read response body
Note: this enforcement is applied by the HTTPConnection class. The
HTTPResponse class does not enforce this state machine, which
implies sophisticated clients may accelerate the request/response
pipeline. Caution should be taken, though: accelerating the states
beyond the above pattern may imply knowledge of the server's
connection-close behavior for certain requests. For example, it
is impossible to tell whether the server will close the connection
UNTIL the response headers have been read; this means that further
requests cannot be placed into the pipeline until it is known that
the server will NOT be closing the connection.
Logical State __state __response
------------- ------- ----------
Idle _CS_IDLE None
Request-started _CS_REQ_STARTED None
Request-sent _CS_REQ_SENT None
Unread-response _CS_IDLE
Req-started-unread-response _CS_REQ_STARTED
Req-sent-unread-response _CS_REQ_SENT
N)urlsplit)HTTPResponseHTTPConnection
HTTPExceptionNotConnectedUnknownProtocolUnknownTransferEncodingUnimplementedFileModeIncompleteRead
InvalidURLImproperConnectionStateCannotSendRequestCannotSendHeaderResponseNotReady
BadStatusLineLineTooLongRemoteDisconnectederror responsesP i UNKNOWNIdlezRequest-startedzRequest-senti d i s [^:\s][^:\r\n]*s \n(?![ \t])|\r(?![ \t\n])z[ - ]z[ -]> PUTPOSTPATCHc
U R S5 $ ! [ an n[ UR UR UR UR
UR
5 < SXR UR
<S SU< S35 SeSnAff = f)z