Mercurial > code > home > repos > homeauto
changeset 1504:d8eba5a51c1f
try a text/plain response if we think it's a browser asking for the graph
Ignore-this: 3ab9e0c28cd46aff6d93e818a8a5fbbd
darcs-hash:43107cfc2041fb2a1652265c072aa35c945e129f
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 03 Feb 2020 00:50:53 -0800 |
parents | 040e5c578fc1 |
children | 3cdf76755812 |
files | lib/patchablegraph/patchablegraph.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/patchablegraph/patchablegraph.py Sun Feb 02 14:44:42 2020 -0800 +++ b/lib/patchablegraph/patchablegraph.py Mon Feb 03 00:50:53 2020 -0800 @@ -43,6 +43,15 @@ req.set_header('Content-type', 'application/ld+json') graph.serialize(req, format='json-ld', indent=2) else: + print(f'acceptHeader {acceptHeader}') + if acceptHeader.startswith('text/html'): + # browser; should arrange to pick live view + req.set_header('Content-type', 'text/plain') + lines = graph.serialize(format='nquads') + lines.sort() + req.write(''.join(lines)) + return + req.set_header('Content-type', 'application/x-trig') graph.serialize(req, format='trig')