From ecff0c4ec5e630826d6261f99057790011c0fb89 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 31 Jan 2024 14:10:44 +0100 Subject: [PATCH] Woops! --- changedetectionio/content_fetcher.py | 4 +++- changedetectionio/tests/test_request.py | 11 +++++------ changedetectionio/update_worker.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 1de270cb6..124eeae1b 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -748,6 +748,8 @@ class html_requests(Fetcher): if encoding: r.encoding = encoding + self.headers = r.headers + if not r.content or not len(r.content): raise EmptyReply(url=url, status_code=r.status_code) @@ -764,7 +766,7 @@ class html_requests(Fetcher): else: self.content = r.text - self.headers = r.headers + self.raw_content = r.content diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index 9fab7da52..873f0e058 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -72,18 +72,17 @@ def test_headers_in_request(client, live_server): # Re #137 - Examine the JSON index file, it should have only one set of headers entered watches_with_headers = 0 - with open('test-datastore/url-watches.json') as f: - app_struct = json.load(f) - for uuid in app_struct['watching']: - if (len(app_struct['watching'][uuid]['headers'])): + for k, watch in client.application.config.get('DATASTORE').data.get('watching').items(): + if (len(watch['headers'])): watches_with_headers += 1 + # Should be only one with headers set + assert watches_with_headers == 1 + # 'server' http header was automatically recorded for k, watch in client.application.config.get('DATASTORE').data.get('watching').items(): assert 'werkzeug' in watch.get('remote_server_reply') assert 'custom' in watch.get('remote_server_reply') # added in util.py, it should append it with a , to the original one - # Should be only one with headers set - assert watches_with_headers==1 res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index d2a0931cd..469840894 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -494,7 +494,7 @@ class update_worker(threading.Thread): # Record the 'server' header reply, can be used for actions in the future like cloudflare/akamai workarounds try: - server_header = update_handler.fetcher.headers.get('server', '').trim().lower()[:255] + server_header = update_handler.fetcher.headers.get('server', '').strip().lower()[:255] self.datastore.update_watch(uuid=uuid, update_obj={'remote_server_reply': server_header} )