MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_content_length_sync

Method test_content_length_sync

Lib/test/test_httplib.py:1373–1383  ·  view source on GitHub ↗

Check that we don't read past the end of the Content-Length stream

(self)

Source from the content-addressed store, hash-verified

1371 resp.close()
1372
1373 def test_content_length_sync(self):
1374 """Check that we don't read past the end of the Content-Length stream"""
1375 extradata = b"extradata"
1376 expected = b"Hello123\r\n"
1377 sock = FakeSocket(b'HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\n' + expected + extradata)
1378 resp = client.HTTPResponse(sock, method="GET")
1379 resp.begin()
1380 self.assertEqual(resp.read(), expected)
1381 # the file should now have our extradata ready to be read
1382 self.assertEqual(sock.file.read(), extradata) #we read to the end
1383 resp.close()
1384
1385 def test_readlines_content_length(self):
1386 extradata = b"extradata"

Callers

nothing calls this directly

Calls 6

beginMethod · 0.95
readMethod · 0.95
closeMethod · 0.95
FakeSocketClass · 0.70
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected