summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2019-10-30 08:07:49 +0000
committerfw-bot <otis@odoo.com>2019-10-31 11:06:31 +0000
commitd11ba1454a5cda4705526715bc027522bfd90d95 (patch)
treec3b4abf19cc18d1148ac9886629eaad4ae225deb
parent9d2e3fcd61027745b809d2e06282e8e1374244ea (diff)
[FIX] http: disable cache-control header (debug) for wkhtmltopdf
Activate developer mode, generate a report (print an invoice) The report will have missing pieces, like the footer or some part of the header. This is probably caused by wkhtmltopdf not loading properly some resources Wkhtmtopdf generate the same warning message for every problematic resource: "Warning: Received createRequest signal on a disposed ResourceObject's NetworkAccessManager. This might be an indication of an iframe taking too long to load." Related issue on wkhtmltopdf project page: wkhtmltopdf/wkhtmltopdf#1865 wkhtmltopdf/wkhtmltopdf#3933 wkhtmltopdf/wkhtmltopdf#2565 The problem is located in the response that wkhtmltopdf receive: in debug mode the header of the response contains 'Cache-Control: no-cache' which probably create a race condition during the rendering while a second request is attempted to verify the resources. Adding a raw user agent check to not include this header directive fix the problem Notes from odony: We've considered some alternative solutions to preserve the purpose of the DisableCacheMiddleware without having to explicitly test for wkhtmltopdf. * 'Cache-Control: no-cache' (current behavior) breaks wkhtmltopdf rendering * 'Cache-Control: no-store' breaks wkhtmltopdf rendering too * 'Cache-Control: max-age=0' breaks wkhtmltopdf rendering too. It works when increasing the delay to a few seconds, but no magic value will work for very long documents, or it will stop serving its purpose, so it's not a viable option. * 'Cache-Control: must-revalidate' does not break wkhtmltopdf rendering (no duplicate requests at all), but it is not clear from the RFC (https://tools.ietf.org/html/rfc7234#section-5.2.2.1) that it will have the intended effect for our middlewar opw-2086708 Closes #38394 closes odoo/odoo#39634 X-original-commit: 8cac60be37133cabef46dab016a5692876da9e5e Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
-rw-r--r--odoo/http.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/http.py b/odoo/http.py
index 1dc87db6bc7..1484b78b791 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -1243,7 +1243,7 @@ class DisableCacheMiddleware(object):
def start_wrapped(status, headers):
req = werkzeug.wrappers.Request(environ)
root.setup_session(req)
- if req.session and req.session.debug:
+ if req.session and req.session.debug and not 'wkhtmltopdf' in req.headers.get('User-Agent'):
new_headers = [('Cache-Control', 'no-cache')]
for k, v in headers: