(self)
| 289 | |
| 290 | |
| 291 | def check_chunked_transfer(self): |
| 292 | self.log.info("Check HTTP request encoded with chunked transfer") |
| 293 | conn = BitcoinHTTPConnection(self.node) |
| 294 | headers_chunked = conn.headers.copy() |
| 295 | headers_chunked.update({"Transfer-encoding": "chunked"}) |
| 296 | body_chunked = [ |
| 297 | b'{"method": "submitblock", "params": ["', |
| 298 | b'0' * 1000000, |
| 299 | b'1' * 1000000, |
| 300 | b'2' * 1000000, |
| 301 | b'3' * 1000000, |
| 302 | b'"]}' |
| 303 | ] |
| 304 | conn.conn.request( |
| 305 | method='POST', |
| 306 | url='/', |
| 307 | body=iter(body_chunked), |
| 308 | headers=headers_chunked, |
| 309 | encode_chunked=True) |
| 310 | response1 = conn.recv_raw() |
| 311 | assert b'{"result":"high-hash","error":null}\n' in response1 |
| 312 | |
| 313 | self.log.info("Check excessive size HTTP request encoded with chunked transfer") |
| 314 | conn = BitcoinHTTPConnection(self.node) |
| 315 | headers_chunked = conn.headers.copy() |
| 316 | headers_chunked.update({"Transfer-encoding": "chunked"}) |
| 317 | body_chunked = [ |
| 318 | b'{"method": "submitblock", "params": ["', |
| 319 | b'0' * 10000000, |
| 320 | b'1' * 10000000, |
| 321 | b'2' * 10000000, |
| 322 | b'3' * 10000000, |
| 323 | b'"]}' |
| 324 | ] |
| 325 | try: |
| 326 | conn.conn.request( |
| 327 | method='POST', |
| 328 | url='/', |
| 329 | body=iter(body_chunked), |
| 330 | headers=headers_chunked, |
| 331 | encode_chunked=True) |
| 332 | self.log.info("Client finished sending request before connection was terminated") |
| 333 | except NETWORK_ERRORS: |
| 334 | self.log.info("Client did not finish sending request before connection was terminated") |
| 335 | |
| 336 | # The server will send a 413 response and disconnect but due to a race |
| 337 | # condition, the python client may or may not read the response before |
| 338 | # detecting the broken socket (which it may still be trying to write to). |
| 339 | try: |
| 340 | response2 = conn.conn.getresponse() |
| 341 | assert_equal(response2.status, http.client.REQUEST_ENTITY_TOO_LARGE) |
| 342 | self.log.info(f"Client got expected response status {response2.status}") |
| 343 | assert conn.sock_closed() |
| 344 | except NETWORK_ERRORS: |
| 345 | self.log.info("Client did not read response before disconnecting") |
| 346 | |
| 347 | |
| 348 | def check_idle_timeout(self): |
no test coverage detected