changeset 3139:bc0ef78bb07a

requestKey uses POST to avoid cache
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 16 Mar 2021 21:02:40 +0000
parents 21ee5bcf80a3
children 7180d6a2a271
files Dockerfile apache/000-default.conf js/core.js python/pythonServer.py
diffstat 4 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dockerfile	Tue Mar 16 21:02:40 2021 +0000
@@ -0,0 +1,8 @@
+FROM php:8-apache
+
+RUN a2enmod rewrite
+RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
+
+COPY ./apache/000-default.conf /etc/apache2/sites-available/000-default.conf
+
+EXPOSE 80
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apache/000-default.conf	Tue Mar 16 21:02:40 2021 +0000
@@ -0,0 +1,8 @@
+<VirtualHost *:80>
+
+  ServerAdmin admin@localhost
+  DocumentRoot /var/www/html
+  ErrorLog ${APACHE_LOG_DIR}/error.log
+  CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+</VirtualHost>
--- a/js/core.js	Tue Nov 12 16:09:53 2019 +0000
+++ b/js/core.js	Tue Mar 16 21:02:40 2021 +0000
@@ -3893,7 +3893,7 @@
         function keyPromise() {
             return new Promise(function (resolve, reject) {
                 var req = new XMLHttpRequest();
-                req.open("GET", returnURL + "php/requestKey.php?saveFilenamePrefix=" + parent.filenamePrefix, true);
+                req.open("POST", returnURL + "php/requestKey.php?saveFilenamePrefix=" + parent.filenamePrefix, true);
                 req.onload = function () {
                     // This is called even on 404 etc
                     // so check the status
--- a/python/pythonServer.py	Tue Nov 12 16:09:53 2019 +0000
+++ b/python/pythonServer.py	Tue Mar 16 21:02:40 2021 +0000
@@ -83,6 +83,7 @@
             s.send_header("Content-type", 'application/javascript')
         else:
             s.send_header("Content-type", 'application/octet-stream')
+        s.send_header("Cache-Control", "no-cache")
         fileRead = fileDump.read()
         s.send_header("Content-Length", len(fileRead))
         s.end_headers()
@@ -117,6 +118,7 @@
             fileDump = open(fpath, 'rb')
             fileBytes = fileDump.read()
             fileDump.close()
+        s.send_header("Cache-Control", "no-cache")
         s.send_header("Content-Length", len(fileBytes))
         s.end_headers()
         s.wfile.write(fileBytes)
@@ -137,7 +139,8 @@
     if prefix == None:
         prefix = "save"
     s.send_response(200)
-    s.send_header("Content-type", "application/xml");
+    s.send_header("Content-Type", "application/xml")
+    s.send_header("Cache-Control", "no-cache")
     s.end_headers()
     reply = "<response><state>OK</state><key>"+key+"</key></response>"
     if sys.version_info[0] == 2:
@@ -288,15 +291,16 @@
 
 def http_do_GET(request):
     global pseudo_index
+    print(request.path)
     if(request.client_address[0] == "127.0.0.1"):
         if (request.path == "/favicon.ico"):
             send404(request)
         elif (request.path.split('?',1)[0] == "/php/requestKey.php"):
-            requestKey(request);
+            requestKey(request)
         elif (request.path.split('?',1)[0] == "/php/pool.php"):
-            poolXML(request);
+            poolXML(request)
         elif (request.path.split('?',1)[0] == "/php/test_write.php"):
-            testSave(request);
+            testSave(request)
         else:
             request.path = request.path.split('?',1)[0]
             if (request.path == '/'):
@@ -314,6 +318,8 @@
     if(request.client_address[0] == "127.0.0.1"):
         if (request.path.rsplit('?',1)[0] == "/save" or request.path.rsplit('?',1)[0] == "/php/save.php"):
             saveFile(request)
+        elif (request.path.split('?',1)[0] == "/php/requestKey.php"):
+            requestKey(request)
         else:
             send404(request)