Skip to content

Commit

Permalink
Merge pull request #110 from Zeroji/custom-request-headers
Browse files Browse the repository at this point in the history
Add custom request headers
  • Loading branch information
d-Rickyy-b committed Oct 6, 2019
2 parents 6b291e2 + 5043e0c commit 6ce23c4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pastepwn/util/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def __new__(cls, *args, **kwargs):
Request._instance = super(Request, cls).__new__(cls)
return Request._instance

def __init__(self, proxies=None):
def __init__(self, proxies=None, headers=None):
if not self._initialized:
self.logger = logging.getLogger(__name__)
self.session = Session()
self.proxies = proxies
self.headers = headers
self.logger.info("Using the following custom proxies: {}".format(proxies))
self.logger.info("Using the following system proxies: {}".format(utils.get_environ_proxies("https://example.com")))
self._initialized = True
Expand All @@ -34,6 +35,9 @@ def _request_wrapper(self, data, timeout, *args, **kwargs):
"User-Agent": "pastepwn (https://github.com/d-Rickyy-b/pastepwn)"
}

if self.headers is not None:
headers.update(self.headers)

try:
response = self.session.request(headers=headers, proxies=self.proxies, data=data, timeout=timeout, *args, **kwargs)
response_data = response.content.decode("utf-8")
Expand Down

0 comments on commit 6ce23c4

Please sign in to comment.