changeset 2981:24681d53ee7a

Python 2.7 would incorrectly parse headers
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 19 Jan 2018 13:03:18 +0000
parents 68e5a789702f
children b3ebd07e7a0f b89e760e091b
files python/pythonServer.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/python/pythonServer.py	Fri Jan 12 15:49:54 2018 +0000
+++ b/python/pythonServer.py	Fri Jan 19 13:03:18 2018 +0000
@@ -62,16 +62,17 @@
         st = s.path.rsplit(',')
         lenSt = len(st)
         fmt = st[lenSt-1].rsplit('.')
+        fmt = fmt[len(fmt)-1]
         fpath = "../"+urllib2.unquote(s.path)
         size = os.path.getsize(fpath)
-        fileDump = open(fpath)
+        fileDump = open(fpath, mode='rb')
         s.send_response(200)
 
-        if (fmt[1] == 'html'):
+        if (fmt == 'html'):
             s.send_header("Content-type", 'text/html')
-        elif (fmt[1] == 'css'):
+        elif (fmt == 'css'):
             s.send_header("Content-type", 'text/css')
-        elif (fmt[1] == 'js'):
+        elif (fmt == 'js'):
             s.send_header("Content-type", 'application/javascript')
         else:
             s.send_header("Content-type", 'application/octet-stream')