7
7
ConnectionClosed ,
8
8
Data ,
9
9
EndOfMessage ,
10
- Event ,
11
10
InformationalResponse ,
12
11
Request ,
13
12
Response ,
17
16
CLOSED ,
18
17
DONE ,
19
18
ERROR ,
20
- IDLE ,
21
19
MIGHT_SWITCH_PROTOCOL ,
22
20
MUST_CLOSE ,
23
21
SEND_BODY ,
@@ -48,15 +46,15 @@ def test__keep_alive() -> None:
48
46
)
49
47
)
50
48
assert not _keep_alive (
51
- Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" ) # type: ignore[arg-type]
49
+ Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" )
52
50
)
53
51
54
- assert _keep_alive (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
52
+ assert _keep_alive (Response (status_code = 200 , headers = []))
55
53
assert not _keep_alive (Response (status_code = 200 , headers = [("Connection" , "close" )]))
56
54
assert not _keep_alive (
57
55
Response (status_code = 200 , headers = [("Connection" , "a, b, cLOse, foo" )])
58
56
)
59
- assert not _keep_alive (Response (status_code = 200 , headers = [], http_version = "1.0" )) # type: ignore[arg-type]
57
+ assert not _keep_alive (Response (status_code = 200 , headers = [], http_version = "1.0" ))
60
58
61
59
62
60
def test__body_framing () -> None :
@@ -135,7 +133,7 @@ def test_Connection_basics_and_content_length() -> None:
135
133
assert p .conn [CLIENT ].their_http_version is None
136
134
assert p .conn [SERVER ].their_http_version == b"1.1"
137
135
138
- data = p .send (SERVER , InformationalResponse (status_code = 100 , headers = [])) # type: ignore[arg-type]
136
+ data = p .send (SERVER , InformationalResponse (status_code = 100 , headers = []))
139
137
assert data == b"HTTP/1.1 100 \r \n \r \n "
140
138
141
139
data = p .send (SERVER , Response (status_code = 200 , headers = [("Content-Length" , "11" )]))
@@ -247,7 +245,7 @@ def test_client_talking_to_http10_server() -> None:
247
245
assert c .our_state is DONE
248
246
# No content-length, so Http10 framing for body
249
247
assert receive_and_get (c , b"HTTP/1.0 200 OK\r \n \r \n " ) == [
250
- Response (status_code = 200 , headers = [], http_version = "1.0" , reason = b"OK" ) # type: ignore[arg-type]
248
+ Response (status_code = 200 , headers = [], http_version = "1.0" , reason = b"OK" )
251
249
]
252
250
assert c .our_state is MUST_CLOSE
253
251
assert receive_and_get (c , b"12345" ) == [Data (data = b"12345" )]
@@ -261,14 +259,14 @@ def test_server_talking_to_http10_client() -> None:
261
259
# No content-length, so no body
262
260
# NB: no host header
263
261
assert receive_and_get (c , b"GET / HTTP/1.0\r \n \r \n " ) == [
264
- Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" ), # type: ignore[arg-type]
262
+ Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" ),
265
263
EndOfMessage (),
266
264
]
267
265
assert c .their_state is MUST_CLOSE
268
266
269
267
# We automatically Connection: close back at them
270
268
assert (
271
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
269
+ c .send (Response (status_code = 200 , headers = []))
272
270
== b"HTTP/1.1 200 \r \n Connection: close\r \n \r \n "
273
271
)
274
272
@@ -356,7 +354,7 @@ def test_automagic_connection_close_handling() -> None:
356
354
p .send (
357
355
SERVER ,
358
356
# no header here...
359
- [Response (status_code = 204 , headers = []), EndOfMessage ()], # type: ignore[arg-type]
357
+ [Response (status_code = 204 , headers = []), EndOfMessage ()],
360
358
# ...but oh look, it arrived anyway
361
359
expect = [
362
360
Response (status_code = 204 , headers = [("connection" , "close" )]),
@@ -390,7 +388,7 @@ def setup() -> ConnectionPair:
390
388
391
389
# Disabled by 100 Continue
392
390
p = setup ()
393
- p .send (SERVER , InformationalResponse (status_code = 100 , headers = [])) # type: ignore[arg-type]
391
+ p .send (SERVER , InformationalResponse (status_code = 100 , headers = []))
394
392
for conn in p .conns :
395
393
assert not conn .client_is_waiting_for_100_continue
396
394
assert not conn .they_are_waiting_for_100_continue
@@ -471,7 +469,7 @@ def test_max_incomplete_event_size_countermeasure() -> None:
471
469
# Even more data comes in, still no problem
472
470
c .receive_data (b"X" * 1000 )
473
471
# We can respond and reuse to get the second pipelined request
474
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
472
+ c .send (Response (status_code = 200 , headers = []))
475
473
c .send (EndOfMessage ())
476
474
c .start_next_cycle ()
477
475
assert get_all_events (c ) == [
@@ -481,7 +479,7 @@ def test_max_incomplete_event_size_countermeasure() -> None:
481
479
# But once we unpause and try to read the next message, and find that it's
482
480
# incomplete and the buffer is *still* way too large, then *that's* a
483
481
# problem:
484
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
482
+ c .send (Response (status_code = 200 , headers = []))
485
483
c .send (EndOfMessage ())
486
484
c .start_next_cycle ()
487
485
with pytest .raises (RemoteProtocolError ):
@@ -547,7 +545,7 @@ def test_pipelining() -> None:
547
545
548
546
assert c .next_event () is PAUSED
549
547
550
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
548
+ c .send (Response (status_code = 200 , headers = []))
551
549
c .send (EndOfMessage ())
552
550
assert c .their_state is DONE
553
551
assert c .our_state is DONE
@@ -564,7 +562,7 @@ def test_pipelining() -> None:
564
562
EndOfMessage (),
565
563
]
566
564
assert c .next_event () is PAUSED
567
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
565
+ c .send (Response (status_code = 200 , headers = []))
568
566
c .send (EndOfMessage ())
569
567
c .start_next_cycle ()
570
568
@@ -574,7 +572,7 @@ def test_pipelining() -> None:
574
572
]
575
573
# Doesn't pause this time, no trailing data
576
574
assert c .next_event () is NEED_DATA
577
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
575
+ c .send (Response (status_code = 200 , headers = []))
578
576
c .send (EndOfMessage ())
579
577
580
578
# Arrival of more data triggers pause
@@ -683,7 +681,7 @@ def setup() -> ConnectionPair:
683
681
sc .send (EndOfMessage ())
684
682
sc .start_next_cycle ()
685
683
assert get_all_events (sc ) == [
686
- Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" ), # type: ignore[arg-type]
684
+ Request (method = "GET" , target = "/" , headers = [], http_version = "1.0" ),
687
685
EndOfMessage (),
688
686
]
689
687
@@ -845,7 +843,7 @@ def test_pipelined_close() -> None:
845
843
EndOfMessage (),
846
844
]
847
845
assert c .states [CLIENT ] is DONE
848
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
846
+ c .send (Response (status_code = 200 , headers = []))
849
847
c .send (EndOfMessage ())
850
848
assert c .states [SERVER ] is DONE
851
849
c .start_next_cycle ()
@@ -860,7 +858,7 @@ def test_pipelined_close() -> None:
860
858
ConnectionClosed (),
861
859
]
862
860
assert c .states == {CLIENT : CLOSED , SERVER : SEND_RESPONSE }
863
- c .send (Response (status_code = 200 , headers = [])) # type: ignore[arg-type]
861
+ c .send (Response (status_code = 200 , headers = []))
864
862
c .send (EndOfMessage ())
865
863
assert c .states == {CLIENT : CLOSED , SERVER : MUST_CLOSE }
866
864
c .send (ConnectionClosed ())
@@ -919,7 +917,7 @@ def test_errors() -> None:
919
917
# But we can still yell at the client for sending us gibberish
920
918
if role is SERVER :
921
919
assert (
922
- c .send (Response (status_code = 400 , headers = [])) # type: ignore[arg-type]
920
+ c .send (Response (status_code = 400 , headers = []))
923
921
== b"HTTP/1.1 400 \r \n Connection: close\r \n \r \n "
924
922
)
925
923
@@ -946,8 +944,8 @@ def conn(role: Type[Sentinel]) -> Connection:
946
944
http_version = "1.0" ,
947
945
)
948
946
elif role is SERVER :
949
- good = Response (status_code = 200 , headers = []) # type: ignore[arg-type, assignment]
950
- bad = Response (status_code = 200 , headers = [], http_version = "1.0" ) # type: ignore[arg-type, assignment]
947
+ good = Response (status_code = 200 , headers = []) # type: ignore[assignment]
948
+ bad = Response (status_code = 200 , headers = [], http_version = "1.0" ) # type: ignore[assignment]
951
949
# Make sure 'good' actually is good
952
950
c = conn (role )
953
951
c .send (good )
@@ -1063,14 +1061,14 @@ def setup(method: bytes, http_version: bytes) -> Connection:
1063
1061
# No Content-Length, HTTP/1.1 peer, should use chunked
1064
1062
c = setup (method , b"1.1" )
1065
1063
assert (
1066
- c .send (Response (status_code = 200 , headers = [])) == b"HTTP/1.1 200 \r \n " # type: ignore[arg-type]
1064
+ c .send (Response (status_code = 200 , headers = [])) == b"HTTP/1.1 200 \r \n "
1067
1065
b"Transfer-Encoding: chunked\r \n \r \n "
1068
1066
)
1069
1067
1070
1068
# No Content-Length, HTTP/1.0 peer, frame with connection: close
1071
1069
c = setup (method , b"1.0" )
1072
1070
assert (
1073
- c .send (Response (status_code = 200 , headers = [])) == b"HTTP/1.1 200 \r \n " # type: ignore[arg-type]
1071
+ c .send (Response (status_code = 200 , headers = [])) == b"HTTP/1.1 200 \r \n "
1074
1072
b"Connection: close\r \n \r \n "
1075
1073
)
1076
1074
0 commit comments