From 3fa1408958bd984521fbac5437f82f2b8f6c2140 Mon Sep 17 00:00:00 2001 From: Matthew Zipkin Date: Wed, 12 Mar 2025 13:35:28 -0400 Subject: [PATCH] test: cover "chunked" Transfer-Encoding --- test/functional/interface_http.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/functional/interface_http.py b/test/functional/interface_http.py index 324a0883516..695fee638d8 100755 --- a/test/functional/interface_http.py +++ b/test/functional/interface_http.py @@ -105,6 +105,28 @@ class HTTPBasicsTest (BitcoinTestFramework): out1 = conn.getresponse() assert_equal(out1.status, http.client.BAD_REQUEST) + 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.restart_node(2, extra_args=["-rpcservertimeout=1"]) # This is the amount of time the server will wait for a client to