Skip to content

Commit

Permalink
Always use default header for accept-language, because it is unlikely…
Browse files Browse the repository at this point in the history
… to vary very much. Let headers remain on requests where the header VALUE differs.
  • Loading branch information
cyberw committed Mar 13, 2024
1 parent bf9bb3b commit 0ec2638
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion har2locust/default_plugins/default_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def default_headers(entries: list[dict], _args):
else:
for dh in default_headers[:]: # pylint: disable=unsubscriptable-object
for h in headers:
if h["name"] == "accept-language":
# accept-language is likely to be common among most requests so we never remove it from default headers
# (instead it will be overridden in the specific requests where it differs)
break
if dh["name"] == h["name"]:
if dh["value"] != h["value"]:
logging.debug(
Expand All @@ -40,7 +44,7 @@ def default_headers(entries: list[dict], _args):
headers = e["request"]["headers"]
for h in headers[:]:
for dh in default_headers:
if h["name"] == dh["name"]:
if h["name"] == dh["name"] and h["value"] == dh["value"]:
headers.remove(dh)
headers[:] = sorted(headers, key=lambda item: item["name"])

Expand Down

0 comments on commit 0ec2638

Please sign in to comment.