(self)
| 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 | |
| 290 | class EchoHandler(RequestHandler): |
nothing calls this directly
no test coverage detected