diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 63b964559..1d7c757d7 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -152,11 +152,16 @@ {{ render_field(form.headers, rows=5, placeholder="Example Cookie: foobar User-Agent: wonderbra 1.0") }} - {% if has_extra_headers_file %} +
- Alert! Extra headers file found and will be added to this watch! + {% if has_extra_headers_file %} + Alert! Extra headers file found and will be added to this watch! + {% else %} + Headers can be read from a textfile headers.txt in your data-directory, or per-watch in the watch sub-directory of the main data directory.
+ Also supported is tagname.txt in your data-directory (all letters in tagname converted to lowercase) + {% endif %}
- {% endif %} +
{{ render_field(form.body, rows=5, placeholder="Example diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index b3205d152..992a64287 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -1,7 +1,7 @@ import json import time from flask import url_for -from . util import set_original_response, set_modified_response, live_server_setup +from . util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks def test_setup(live_server): live_server_setup(live_server) @@ -234,3 +234,62 @@ def test_method_in_request(client, live_server): # Should be only one with method set to PATCH assert watches_with_method == 1 + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) + assert b'Deleted' in res.data + +def test_headers_textfile_in_request(client, live_server): + # Add our URL to the import page + test_url = url_for('test_headers', _external=True) + + # Add the test URL twice, we will check + res = client.post( + url_for("import_page"), + data={"urls": test_url}, + follow_redirects=True + ) + assert b"1 Imported" in res.data + + time.sleep(1) + + res = client.post( + url_for("import_page"), + data={"urls": test_url}, + follow_redirects=True + ) + assert b"1 Imported" in res.data + + time.sleep(3) + + # Add some headers to a request + res = client.post( + url_for("edit_page", uuid="first"), + data={ + "url": test_url, + "tag": "", + "fetch_backend": "html_requests", + "headers": "xxx:ooo\ncool:yeah\r\n"}, + follow_redirects=True + ) + assert b"Updated watch." in res.data + wait_for_all_checks(client) + + + with open('test-datastore/headers.txt', 'w') as f: + f.write("global-header: nice\r\nnext-global-header: nice") + + client.get(url_for("form_watch_checknow"), follow_redirects=True) + + # Give the thread time to pick it up + wait_for_all_checks(client) + # The service should echo back the request verb + res = client.get( + url_for("preview_page", uuid="first"), + follow_redirects=True + ) + assert b"global-header: nice" in res.data + assert b"next-global-header: nice" in res.data + assert b"cool: yeah" in res.data + + #unlink headers.txt on start/stop + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) + assert b'Deleted' in res.data \ No newline at end of file