Skip to content

Commit d3e5642

Browse files
committed
Added user agent option
1 parent 4e42e90 commit d3e5642

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ Usage: htrace [OPTIONS] URL
88
Options:
99
-T, --timeout INTEGER Request timeout in seconds
1010
-a, --accept TEXT Accept header value
11+
-b, --body Show response body
1112
-j, --json Report in JSON
1213
-k, --insecure Don't verify certificates
13-
-b, --body Show response body
1414
-L, --link-type TEXT Follow link header with type
15-
-R, --link-rel TEXT Follow link header with rel
1615
-P, --link-profile TEXT Follow link header with profile
16+
-R, --link-rel TEXT Follow link header with rel
17+
-U, --user-agent TEXT User agent header value
1718
--help Show this message and exit.
1819
```
1920

htrace/__main__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ def cbLinkFollow(response, *args, **kwargs):
6969
@click.argument("url")
7070
@click.option("-T", "--timeout", default=10, help="Request timeout in seconds")
7171
@click.option("-a", "--accept", default="*/*", help="Accept header value")
72+
@click.option("-b", "--body", is_flag=True, help="Show response body")
7273
@click.option("-j", "--json", "json_report", is_flag=True, help="Report in JSON")
7374
@click.option("-k", "--insecure", default=False, is_flag=True, help="Don't verify certificates")
74-
@click.option("-b", "--body", is_flag=True, help="Show response body")
7575
@click.option("-L", "--link-type", default=None, help="Follow link header with type")
76-
@click.option("-R", "--link-rel", default='alternate', help="Follow link header with rel")
7776
@click.option("-P", "--link-profile", default=None, help="Follow link header with profile")
78-
def main(url, timeout, accept, json_report, insecure, body, link_type, link_rel, link_profile):
77+
@click.option("-R", "--link-rel", default='alternate', help="Follow link header with rel")
78+
@click.option("-U", "--user-agent", default=None, help="User agent header value")
79+
def main(url, timeout, accept, body, json_report, insecure, link_type, link_profile, link_rel, user_agent):
7980
if insecure:
8081
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
8182

@@ -89,6 +90,8 @@ def main(url, timeout, accept, json_report, insecure, body, link_type, link_rel,
8990
"Accept": accept,
9091
"User-Agent": htrace.USER_AGENT,
9192
}
93+
if not user_agent is None:
94+
headers["User-Agent"] = user_agent
9295
hooks = {
9396
'response': [cbUrl, cbLinkFollow]
9497
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "htrace"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "Tracing HTTP requests over redirects, link headers"
55
authors = ["datadavev <[email protected]>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)