Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion woof
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ class FileServHTTPRequestHandler (http.server.BaseHTTPRequestHandler):


def do_GET (self):
return self.get_or_head ()

def do_HEAD (self):
return self.get_or_head (True)

def get_or_head (self, headers_only=False):
global maxdownloads, cpid, compressed, upload

# Form for uploading a file
Expand All @@ -186,6 +192,10 @@ class FileServHTTPRequestHandler (http.server.BaseHTTPRequestHandler):
self.send_header ("Content-Type", "text/html")
self.send_header ("Content-Length", str (len (txt)))
self.end_headers ()

if headers_only:
return

self.wfile.write (txt)
return

Expand Down Expand Up @@ -216,10 +226,15 @@ class FileServHTTPRequestHandler (http.server.BaseHTTPRequestHandler):
self.send_header ("Content-Type", "text/html")
self.send_header ("Content-Length", str (len (txt)))
self.end_headers ()

if headers_only:
return

self.wfile.write (txt)
return

maxdownloads -= 1
if not headers_only:
maxdownloads -= 1

# let a separate process handle the actual download, so that
# multiple downloads can happen simultaneously.
Expand Down Expand Up @@ -248,6 +263,9 @@ class FileServHTTPRequestHandler (http.server.BaseHTTPRequestHandler):
os.path.getsize (self.filename))
self.end_headers ()

if headers_only:
return

try:
if type == "file":
datafile = open (self.filename, "rb")
Expand Down