Moved redirect functionality to extra class

This commit is contained in:
Sebastian Lohff 2012-04-26 15:45:51 +02:00
parent c010709827
commit a1b08ba10a
1 changed files with 7 additions and 7 deletions

View File

@ -37,14 +37,8 @@ def getDateStrNow():
now = datetime.datetime.fromtimestamp(time.mktime(time.gmtime()))
return now.strftime("%a, %d %b %Y %H:%M:%S GMT")
class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler):
fileName = "Undefined"
filePath = "/dev/null"
fileLength = 0
startTime = getDateStrNow()
blockSize = 1024 * 1024
def checkAndDoRedirect(self):
""" If request didn't request self.fileName redirect to self.fileName.
@ -56,6 +50,12 @@ class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return True
return False
class FileHandler(FileBaseHandler):
filePath = "/dev/null"
fileLength = 0
startTime = getDateStrNow()
blockSize = 1024 * 1024
def do_HEAD(self):
if self.checkAndDoRedirect():
return