@@ -36,6 +36,39 @@ def test_app_exits_early(self):
3636 b'HTTP/1.0 500 Internal Server Error' )
3737 self .assertEqual (body , b'Internal Server Error' )
3838
39+ def test_double_start (self ):
40+ header , body = getcontents (
41+ host = ASGI_HOST ,
42+ port = ASGI_PORT ,
43+ raw = b'GET /start HTTP/1.0\r \n \r \n '
44+ )
45+
46+ self .assertEqual (header [:header .find (b'\r \n ' )],
47+ b'HTTP/1.0 500 Internal Server Error' )
48+ self .assertEqual (body , b'response already started' )
49+
50+ def test_body_before_start (self ):
51+ header , body = getcontents (
52+ host = ASGI_HOST ,
53+ port = ASGI_PORT ,
54+ raw = b'GET /body HTTP/1.0\r \n \r \n '
55+ )
56+
57+ self .assertEqual (header [:header .find (b'\r \n ' )],
58+ b'HTTP/1.0 500 Internal Server Error' )
59+ self .assertEqual (body , b'response not started' )
60+
61+ def test_invalid_message_type (self ):
62+ header , body = getcontents (
63+ host = ASGI_HOST ,
64+ port = ASGI_PORT ,
65+ raw = b'GET /invalid HTTP/1.0\r \n \r \n '
66+ )
67+
68+ self .assertEqual (header [:header .find (b'\r \n ' )],
69+ b'HTTP/1.0 500 Internal Server Error' )
70+ self .assertEqual (body , b'invalid ASGI message type' )
71+
3972 def test_get_ok_10 (self ):
4073 header , body = getcontents (host = ASGI_HOST ,
4174 port = ASGI_PORT ,
@@ -136,9 +169,6 @@ def test_sec_response_splitting(self):
136169 self .assertEqual (header [:header .find (b'\r \n ' )],
137170 b'HTTP/1.1 500 Internal Server Error' )
138171 self .assertFalse (b'\r \n Content-Type: text/plain' in header )
139- self .assertTrue (
140- b'name or value cannot contain illegal characters' in body
141- )
142172
143173 def test_websocket (self ):
144174 header , body = getcontents (
0 commit comments