From 68e186deff9eeb2a8ccffdb0e4b4704b229f7478 Mon Sep 17 00:00:00 2001 From: Nick Daly Date: Sun, 8 Dec 2013 11:46:33 -0600 Subject: [PATCH] Finally fix firstboot redirect problems. This issue was easy to solve once I started using the Live HTTP Headers Firefox extension to debug it: https://addons.mozilla.org/en-US/firefox/addon/live-http-headers/ With this particular InternalRedirect, CherryPy inexplicably responds with a 301 ("Moved Permanently") unless we manually tell it to use a 307 ("Moved Temporarily") response code. I don't know why CherryPy does this, and it may be indicative of a deeper problem that I don't currently have time to debug, as the request-response process for redirecting from http://(server)/plinth to https://(server)/plinth/firstboot is ridiculous and contains about twice as many requests as I would've expected. --- plinth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plinth.py b/plinth.py index a9bab7b4c..d4f17f601 100755 --- a/plinth.py +++ b/plinth.py @@ -60,7 +60,10 @@ class Root(plugin_mount.PagePlugin): # if we created a new user db, make sure it can't be read by everyone userdb_fname = '{}.sqlite3'.format(cfg.user_db) os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) - raise cherrypy.InternalRedirect('firstboot') + # cherrypy.InternalRedirect throws a 301, causing the + # browser to cache the redirect, preventing the user from + # navigating to /plinth until the browser is restarted. + raise cherrypy.HTTPRedirect('firstboot', 307) elif db['state'] < 5: cfg.log("First Boot state = %d" % db['state']) raise cherrypy.InternalRedirect('firstboot/state%d' % db['state'])