Minor update

This commit is contained in:
Miroslav Stampar
2019-11-14 12:51:09 +01:00
parent 8d877de9b5
commit aa9ff9e8a6
3 changed files with 13 additions and 3 deletions

View File

@@ -133,7 +133,9 @@ class ReqHandler(BaseHTTPRequestHandler):
self.send_response(OK)
self.send_header("Content-type", "text/html")
self.send_header("Connection", "close")
self.end_headers()
if not self.raw_requestline.startswith(b"HEAD"):
self.end_headers()
try:
with _lock:
@@ -152,7 +154,11 @@ class ReqHandler(BaseHTTPRequestHandler):
except Exception as ex:
output = "%s: %s" % (re.search(r"'([^']+)'", str(type(ex))).group(1), ex)
self.wfile.write(output.encode("utf8"))
if self.raw_requestline.startswith(b"HEAD"):
self.send_header("Content-Length", str(len(output)))
self.end_headers()
else:
self.wfile.write(output.encode("utf8"))
else:
self.send_response(NOT_FOUND)
self.send_header("Connection", "close")
@@ -164,6 +170,9 @@ class ReqHandler(BaseHTTPRequestHandler):
def do_PUT(self):
self.do_REQUEST()
def do_HEAD(self):
self.do_REQUEST()
def do_POST(self):
length = int(self.headers.get("Content-length", 0))
if length: