Skip to content

Commit 53e9fcb

Browse files
authored
Merge pull request jullrich#6 from Matir/urlfix
Fix URLs containing the hostname in the path.
2 parents dac7a1a + 41a02cc commit 53e9fcb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pcap2curl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def payload2curl(p):
2020
host_header = re.search("^Host: (.*)", line)
2121
host_name = host_header.group(1)
2222

23-
if host_name not in url:
24-
url = "http://{}/{}".format(host_name, url)
25-
curl = "curl '{}' \\\n -X {} \\\n".format(url, method)
26-
curl += " \\\n".join(headers)
23+
proto_host = 'http://{}/'.format(host_name)
24+
if not url.startswith(proto_host):
25+
url = "{}{}".format(proto_host, url[1:] if url[0] == "/" else url)
26+
curl = "curl '{}' \\\n -X {} \\\n ".format(url, method)
27+
curl += " \\\n ".join(headers)
2728
return curl
2829

2930

0 commit comments

Comments
 (0)