Skip to content

Commit bb8f0d0

Browse files
author
AutomatedTester
committed
added headers support. fixes AutomatedTester#1
1 parent 91d1e56 commit bb8f0d0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

browsermobproxy/client.py

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ def __init__(self, url):
1818
url_parts = self.host.split(":")
1919
self.proxy = url_parts[0] + ":" + url_parts[1] + ":" + str(self.port)
2020

21+
def headers(self, headers):
22+
"""
23+
This sets the headers that will set by the proxy on all requests
24+
:Args:
25+
- headers: this is a dictionary of the headers to be set
26+
"""
27+
if not isinstance(headers, dict):
28+
raise TypeError("headers needs to be dictionary")
29+
30+
requests.post('%s/proxy/%s/har' % (self.host, self.port),
31+
json.dumps(headers))
32+
2133
def new_har(self, ref=None):
2234
"""
2335
This sets a new HAR to be recorded

0 commit comments

Comments
 (0)