[FIX] web: _serve_attachment should not trigger redirect loops
When the Bundle mechanism caches bundle files into the ir.attachment table, it can sometimes cache an empty resource file (For example, if a less/saas compiled file results in an empty CSS file) for the bundle URL. The appropriate behavior for _serve_attachment() when the browser loads that bundle URL is to return an empty file (which is the correct content), instead of redirecting again to the same URL, triggering a loop. In addition, this commit removes the special case for returning 204 No Content. This HTTP status code is not really meant for GET requests - returning an empty file with a 304 or 200 code is more appropriate and allows for normal browser caching.
This commit is contained in:
parent
dd4566de37
commit
c2cbb75319
|
@ -109,11 +109,9 @@ class ir_http(osv.AbstractModel):
|
|||
datas = attach[0]['datas'] or ''
|
||||
name = attach[0]['name']
|
||||
|
||||
if not datas:
|
||||
if name.startswith(('http://', 'https://', '/')):
|
||||
return werkzeug.utils.redirect(name, 301)
|
||||
else:
|
||||
return werkzeug.wrappers.Response(status=204) # NO CONTENT
|
||||
if (not datas and name != request.httprequest.path and
|
||||
name.startswith(('http://', 'https://', '/'))):
|
||||
return werkzeug.utils.redirect(name, 301)
|
||||
|
||||
response = werkzeug.wrappers.Response()
|
||||
server_format = openerp.tools.misc.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
|
Loading…
Reference in New Issue