From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
The error in staticfile() happens when the browser tries to open
a recently created file in a separated tab/window but this file
isn't declared in the cherry-py config with tools.staticfile.on,
like '/favicon.ico' for example.
A suitable solution to avoid the error is to force the browser to
download the file instead of opening it. According to the Cherry-py
docs:
"Using "application/x-download" response content-type, you can
tell a browser that a resource should be downloaded onto the
user’s machine rather than displayed."
This patch set the application type of all '.txt' files created
under the /data/logs dir as 'application/x-download'.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
src/wok/config.py.in | 3 +++
tests/test_config.py.in | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/wok/config.py.in b/src/wok/config.py.in
index 677d0ed..c2bcc28 100644
--- a/src/wok/config.py.in
+++ b/src/wok/config.py.in
@@ -202,6 +202,9 @@ class WokConfig(dict):
'/data/logs': {
'tools.staticdir.on': True,
'tools.staticdir.dir': '%s/logs' % paths.state_dir,
+ 'tools.staticdir.content_types': {
+ 'txt': 'application/x-download'
+ },
'tools.nocache.on': False,
'tools.wokauth.on': True,
},
diff --git a/tests/test_config.py.in b/tests/test_config.py.in
index 9b8c851..a4d65bb 100644
--- a/tests/test_config.py.in
+++ b/tests/test_config.py.in
@@ -1,7 +1,7 @@
#
# Project Wok
#
-# Copyright IBM Corp, 2014-2016
+# Copyright IBM Corp, 2014-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -84,6 +84,9 @@ class ConfigTests(unittest.TestCase):
'/data/logs': {
'tools.staticdir.on': True,
'tools.staticdir.dir': '%s/logs' % paths.state_dir,
+ 'tools.staticdir.content_types': {
+ 'txt': 'application/x-download'
+ },
'tools.nocache.on': False,
'tools.wokauth.on': True,
},
--
2.9.3
Show replies by date
Applied. Thanks.
Regards,
Aline Manera