Show full header when using debug scripts

main
Bob Mottram 2025-12-30 13:20:03 +00:00
parent 34e9353cb1
commit 58d5fa7ed0
3 changed files with 21 additions and 14 deletions

View File

@ -286,7 +286,8 @@ def daemon_http_get(self) -> None:
if is_image_file(self.path):
http_404(self, 720)
return
print('GET HTTP LLM scraper poisoned: ' + str(self.headers))
print('GET HTTP LLM scraper poisoned: ' +
str(self.headers).replace('\n', ' '))
msg = html_poisoned(self.server.dictionary,
self.server.twograms)
msg = msg.encode('utf-8')
@ -302,7 +303,8 @@ def daemon_http_get(self) -> None:
# suspicious headers
if contains_suspicious_headers(self.headers):
print('GET HTTP suspicious headers 1 ' + str(self.headers))
print('GET HTTP suspicious headers 1 ' +
str(self.headers).replace('\n', ' '))
http_403(self)
return
@ -340,7 +342,7 @@ def daemon_http_get(self) -> None:
if contains_invalid_chars(str(self.headers)):
print('GET HTTP headers contain invalid characters ' +
str(self.headers))
str(self.headers).replace('\n', ' '))
http_403(self)
return
@ -405,7 +407,8 @@ def daemon_http_get(self) -> None:
http_402(self)
return
# if this is an LLM crawler then feed it some trash
print('GET HTTP LLM scraper poisoned: ' + str(self.headers))
print('GET HTTP LLM scraper poisoned: ' +
str(self.headers).replace('\n', ' '))
msg = html_poisoned(self.server.dictionary,
self.server.twograms)
msg = msg.encode('utf-8')
@ -649,7 +652,7 @@ def daemon_http_get(self) -> None:
str(self.server.getreq_busy))
if self.server.debug:
print(str(self.headers))
print(str(self.headers).replace('\n', ' '))
cookie = None
if self.headers.get('Cookie'):
@ -708,7 +711,7 @@ def daemon_http_get(self) -> None:
print('GET Authorization granted ' + self.path)
else:
print('GET Not authorized ' + self.path + ' ' +
str(self.headers))
str(self.headers).replace('\n', ' '))
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'isAuthorized',
@ -1484,7 +1487,8 @@ def daemon_http_get(self) -> None:
self.headers['Connection'])
http_200(self)
else:
print('WARN: No Accept header ' + str(self.headers))
print('WARN: No Accept header ' +
str(self.headers).replace('\n', ' '))
http_400(self)
return

View File

@ -178,17 +178,20 @@ def daemon_http_post(self) -> None:
mitm = detect_mitm(self)
if mitm:
print('DEBUG: MITM on HTTP POST, ' + str(self.headers))
print('DEBUG: MITM on HTTP POST, ' +
str(self.headers).replace('\n', ' '))
# headers used by LLM scrapers
if 'oai-host-hash' in self.headers:
print('POST HTTP LLM scraper bounced: ' + str(self.headers))
print('POST HTTP LLM scraper bounced: ' +
str(self.headers).replace('\n', ' '))
http_402(self)
return
# suspicious headers
if contains_suspicious_headers(self.headers):
print('POST HTTP suspicious headers 2 ' + str(self.headers))
print('POST HTTP suspicious headers 2 ' +
str(self.headers).replace('\n', ' '))
http_403(self)
return
@ -261,7 +264,7 @@ def daemon_http_post(self) -> None:
if contains_invalid_chars(str(self.headers)):
print('POST HTTP headers contain invalid characters ' +
str(self.headers))
str(self.headers).replace('\n', ' '))
http_403(self)
self.server.postreq_busy = False
return
@ -342,7 +345,7 @@ def daemon_http_post(self) -> None:
authorized = is_authorized(self)
if not authorized and self.server.debug:
print('POST Not authorized')
print(str(self.headers))
print(str(self.headers).replace('\n', ' '))
# if this is a POST to the outbox then check authentication
self.outbox_authenticated = False
@ -1140,7 +1143,7 @@ def daemon_http_post(self) -> None:
not content_type_str.startswith('application/ld+json'):
print("POST is not json: " + self.headers['Content-type'])
if self.server.debug:
print(str(self.headers))
print(str(self.headers).replace('\n', ' '))
length = int(self.headers['Content-length'])
if length < self.server.max_post_length:
try:

View File

@ -9605,7 +9605,7 @@ def _test_replace_gemini_links() -> None:
assert result == expected
def run_all_tests():
def run_all_tests():
base_dir = os.getcwd()
data_dir_testing(base_dir)
print('Running tests...')