diff --git a/scripts/rpc_http_proxy.py b/scripts/rpc_http_proxy.py index da65b93ae..423c94350 100755 --- a/scripts/rpc_http_proxy.py +++ b/scripts/rpc_http_proxy.py @@ -93,7 +93,25 @@ class ServerHandler(BaseHTTPRequestHandler): if self.headers['Authorization'] != 'Basic ' + self.key: self.do_AUTHHEAD() else: - data_string = self.rfile.read(int(self.headers['Content-Length'])) + if "Content-Length" in self.headers: + data_string = self.rfile.read(int(self.headers['Content-Length'])) + elif "chunked" in self.headers.get("Transfer-Encoding", ""): + data_string = b'' + while True: + line = self.rfile.readline().strip() + chunk_length = int(line, 16) + + if chunk_length != 0: + chunk = self.rfile.read(chunk_length) + data_string += chunk + + # Each chunk is followed by an additional empty newline + # that we have to consume. + self.rfile.readline() + + # Finally, a chunk size of 0 is an end indication + if chunk_length == 0: + break try: response = rpc_call(data_string)