websrv_lib: abort request on partial headers.

While searching for the KTHML bug, noticed that partial http requests
would falsely be honoured. Instead, we must check if the full headers
(including the blank line) have been parsed before we dispatch the
request to the virtual handler class.

Conflicts:

	bin/service/websrv_lib.py

bzr revid: p_christ@hol.gr-20101123153558-oh44mjkhwjaebwow
This commit is contained in:
P. Christeas
2010-11-23 17:35:58 +02:00
parent 186b9190f6
commit 1fed78619f
+14 -2
View File
@@ -255,6 +255,12 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
fore.raw_requestline = "%s %s %s\n" % (self.command, path, self.version)
if not fore.parse_request(): # An error code has been sent, just exit
return
if fore.headers.status:
self.log_error("Parse error at headers: %s", fore.headers.status)
self.close_connection = 1
self.send_error(400,"Parse error at HTTP headers")
return
self.request_version = fore.request_version
if auth_provider and auth_provider.realm:
try:
@@ -413,8 +419,14 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
hnd.rfile = self.rfile
hnd.wfile = self.wfile
self.rlpath = self.raw_requestline
self._handle_one_foreign(hnd,npath, vdir.auth_provider)
# print "Handled, closing = ", self.close_connection
try:
self._handle_one_foreign(hnd,npath, vdir.auth_provider)
except IOError, e:
if e.errno == errno.EPIPE:
self.log_message("Could not complete request %s," \
"client closed connection", self.rlpath.rstrip())
else:
raise
return
# if no match:
self.send_error(404, "Path not found: %s" % self.path)