MCPcopy
hub / github.com/tornadoweb/tornado / test_100_continue

Method test_100_continue

tornado/test/httpserver_test.py:260–287  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

258
259 @gen_test
260 def test_100_continue(self):
261 # Run through a 100-continue interaction by hand:
262 # When given Expect: 100-continue, we get a 100 response after the
263 # headers, and then the real response after the body.
264 stream = IOStream(socket.socket())
265 yield stream.connect(("127.0.0.1", self.get_http_port()))
266 yield stream.write(
267 b"\r\n".join(
268 [
269 b"POST /hello HTTP/1.1",
270 b"Host: 127.0.0.1",
271 b"Content-Length: 1024",
272 b"Expect: 100-continue",
273 b"Connection: close",
274 b"\r\n",
275 ]
276 )
277 )
278 data = yield stream.read_until(b"\r\n\r\n")
279 self.assertTrue(data.startswith(b"HTTP/1.1 100 "), data)
280 stream.write(b"a" * 1024)
281 first_line = yield stream.read_until(b"\r\n")
282 self.assertTrue(first_line.startswith(b"HTTP/1.1 200"), first_line)
283 header_data = yield stream.read_until(b"\r\n\r\n")
284 headers = HTTPHeaders.parse(native_str(header_data.decode("latin1")))
285 body = yield stream.read_bytes(int(headers["Content-Length"]))
286 self.assertEqual(body, b"Got 1024 bytes in POST")
287 stream.close()
288
289
290class EchoHandler(RequestHandler):

Callers

nothing calls this directly

Calls 9

connectMethod · 0.95
IOStreamClass · 0.90
joinMethod · 0.80
read_untilMethod · 0.80
read_bytesMethod · 0.80
get_http_portMethod · 0.45
writeMethod · 0.45
parseMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected