Support for ld+json replies

merge-requests/28/head
Bob Mottram 2022-09-11 10:31:11 +01:00
parent 8fea2e2981
commit ac72c6da26
1 changed files with 113 additions and 81 deletions

194
daemon.py
View File

@ -1280,8 +1280,9 @@ class PubServer(BaseHTTPRequestHandler):
msglen = len(msg)
if self._has_accept(calling_domain):
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, True)
else:
@ -1473,12 +1474,12 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
if self._has_accept(calling_domain):
if 'application/ld+json' in self.headers['Accept']:
self._set_headers('application/ld+json', msglen,
None, calling_domain, True)
else:
self._set_headers('application/json', msglen,
None, calling_domain, True)
protocol_str = 'application/json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, True)
else:
self._set_headers('application/ld+json', msglen,
None, calling_domain, True)
@ -1552,12 +1553,12 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
if self._has_accept(calling_domain):
if 'application/ld+json' in self.headers['Accept']:
self._set_headers('application/ld+json', msglen,
None, calling_domain, True)
else:
self._set_headers('application/json', msglen,
None, calling_domain, True)
protocol_str = 'application/json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, True)
else:
self._set_headers('application/ld+json', msglen,
None, calling_domain, True)
@ -7464,12 +7465,12 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
if 'application/ld+json' in self.headers['Accept']:
self._set_headers('application/ld+json', msglen,
None, calling_domain, False)
else:
self._set_headers('application/json', msglen,
None, calling_domain, False)
protocol_str = 'application/json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
if self.server.debug:
print('Sent manifest: ' + calling_domain)
@ -7604,12 +7605,12 @@ class PubServer(BaseHTTPRequestHandler):
msg_str)
msg = msg_str.encode('utf-8')
msglen = len(msg)
if 'application/ld+json' in self.headers['Accept']:
self._set_headers('application/ld+json', msglen,
None, calling_domain, False)
else:
self._set_headers('application/json', msglen,
None, calling_domain, False)
protocol_str = 'application/json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
def _get_exported_theme(self, path: str, base_dir: str,
@ -10820,8 +10821,9 @@ class PubServer(BaseHTTPRequestHandler):
msg_str)
msg = msg_str.encode('utf-8')
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
msglen = len(msg)
self._set_headers(protocol_str, msglen, None,
calling_domain, False)
@ -10927,8 +10929,9 @@ class PubServer(BaseHTTPRequestHandler):
msg_str)
msg = msg_str.encode('utf-8')
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
msglen = len(msg)
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
@ -11049,8 +11052,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -11534,8 +11538,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -11852,8 +11857,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -12012,8 +12018,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -12174,8 +12181,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -12331,7 +12339,11 @@ class PubServer(BaseHTTPRequestHandler):
msg_str)
msg = msg_str.encode('utf-8')
msglen = len(msg)
self._set_headers('application/json', msglen,
protocol_str = 'application/json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
fitness_performance(getreq_start_time,
@ -12487,8 +12499,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -12653,8 +12666,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -12821,8 +12835,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13171,8 +13186,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13323,8 +13339,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13472,8 +13489,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13615,8 +13633,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13753,8 +13772,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13892,8 +13912,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13927,8 +13948,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -13958,8 +13980,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15054,8 +15077,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15208,8 +15232,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15466,8 +15491,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15568,8 +15594,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15925,8 +15952,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -15997,8 +16025,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -16083,8 +16112,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -18493,8 +18523,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)
@ -19846,8 +19877,9 @@ class PubServer(BaseHTTPRequestHandler):
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = 'application/json'
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
if self.headers.get('Accept'):
if 'application/ld+json' in self.headers['Accept']:
protocol_str = 'application/ld+json'
self._set_headers(protocol_str, msglen,
None, calling_domain, False)
self._write(msg)