From 52bebde9dfb4279de4368189b9c1e6f489cfcf0b Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 17 Aug 2015 21:46:33 +0200 Subject: [PATCH] httpserver.py: Pass Content-Length to read call If a POST request is sent to the built-in http server the handling function does not terminate because the rfile.read() function blocks. This patch passes the Content-Length value to the self.rfile.read() function that is required for it to do not block the method. Regarding RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4) the Content-Length header is expected to be sent otherwise this patch assumes a zero length. --- src/httpserver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/httpserver.py b/src/httpserver.py index ee9398904..3baf8b975 100644 --- a/src/httpserver.py +++ b/src/httpserver.py @@ -246,7 +246,8 @@ class SupyHTTPRequestHandler(BaseHTTPRequestHandler): 'CONTENT_TYPE':self.headers['Content-Type'], }) else: - form = self.rfile.read() + content_length = int(self.headers.get('Content-Length', '0')) + form = self.rfile.read(content_length) self.do_X('doPost', form=form) def do_HEAD(self):