From a3328b33bba35adcc96b44175e58f21cd63e31fc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 31 Aug 2021 22:57:49 +0100 Subject: [PATCH] Consolidation of Accept within signed GET --- daemon.py | 5 +++++ session.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/daemon.py b/daemon.py index d1caf928b..3a2cfcb4f 100644 --- a/daemon.py +++ b/daemon.py @@ -907,6 +907,11 @@ class PubServer(BaseHTTPRequestHandler): def _hasAccept(self, callingDomain: str) -> bool: """Do the http headers have an Accept field? """ + if not self.headers.get('Accept'): + if self.headers.get('accept'): + print('Upper case Accept') + self.headers['Accept'] = self.headers['accept'] + if self.headers.get('Accept') or callingDomain.endswith('.b32.i2p'): if not self.headers.get('Accept'): self.headers['Accept'] = \ diff --git a/session.py b/session.py index fd997babf..1ce079984 100644 --- a/session.py +++ b/session.py @@ -191,6 +191,10 @@ def _getJsonSigned(session, url: str, domainFull: str, sessionHeaders: {}, if key == 'Accept' or key == 'User-Agent': continue sessionHeaders[key] = value + # avoid double accept + if sessionHeaders.get('Accept') and sessionHeaders.get('accept'): + del sessionHeaders['Accept'] + sessionHeaders['Origin'] = domainFull print('Signed GET sessionHeaders ' + str(sessionHeaders)) return _getJsonRequest(session, url, domainFull, sessionHeaders,