test: cover "chunked" Transfer-Encoding

This commit is contained in:
Matthew Zipkin 2025-03-12 13:35:28 -04:00
parent 5ec06529bb
commit f259121f30
No known key found for this signature in database
GPG key ID: E7E2984B6289C93A

View file

@ -156,6 +156,29 @@ class HTTPBasicsTest (BitcoinTestFramework):
assert chunks[2].startswith(bytes(f'{tip_height + 1}', 'utf8')) assert chunks[2].startswith(bytes(f'{tip_height + 1}', 'utf8'))
self.log.info("Check HTTP request encoded with chunked transfer")
headers_chunked = headers.copy()
headers_chunked.update({"Transfer-encoding": "chunked"})
body_chunked = [
b'{"method": "submitblock", "params": ["',
b'0A' * 1000000,
b'0B' * 1000000,
b'0C' * 1000000,
b'0D' * 1000000,
b'"]}'
]
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn.connect()
conn.request(
method='POST',
url='/',
body=iter(body_chunked),
headers=headers_chunked,
encode_chunked=True)
out1 = conn.getresponse().read()
assert out1 == b'{"result":"high-hash","error":null}\n'
self.log.info("Check -rpcservertimeout") self.log.info("Check -rpcservertimeout")
# The test framework typically reuses a single persistent HTTP connection # The test framework typically reuses a single persistent HTTP connection
# for all RPCs to a TestNode. Because we are setting -rpcservertimeout # for all RPCs to a TestNode. Because we are setting -rpcservertimeout