Commit afbe688e authored by Fabien Amarger's avatar Fabien Amarger
Browse files

[web.views] add Link alternate in HTTP response header in HTML view

Team: famarger, schabot, nchauvat, fferry, ethieblin
parent a17cbf539a69
......@@ -23,7 +23,7 @@ import http.client
from cubicweb import (NoSelectableObject, ObjectNotFound, ValidationError,
AuthenticationError, UndoTransactionException,
Forbidden)
Forbidden, rdf)
from cubicweb.utils import json_dumps
from cubicweb.predicates import (authenticated_user, anonymous_user,
match_form_params)
......@@ -101,6 +101,10 @@ class ViewController(Controller):
else:
rset = None
vid = req.form.get('vid') or vid_from_rset(req, rset, self._cw.vreg.schema)
if rset and len(rset) == 1:
for mimetype in rdf.RDF_MIMETYPE_TO_FORMAT:
req.headers_out.addRawHeader(
'Link', "<%s>;rel=alternate;type=%s" % (rset.one().cwuri, mimetype))
try:
view = self._cw.vreg['views'].select(vid, req, rset=rset)
except ObjectNotFound:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment