Support for authentication in HTTP plugin methods

This commit is contained in:
Fabio Manganiello 2019-04-11 16:21:39 +02:00
parent 12fefaa220
commit c55deab6cb
1 changed files with 3 additions and 0 deletions

View File

@ -46,6 +46,9 @@ class HttpRequestPlugin(Plugin):
def _exec(self, method, url, output='text', **kwargs):
""" Available output types: text (default), json, binary """
if 'username' in kwargs and 'password' in kwargs:
kwargs['auth'] = (kwargs.pop('username'), kwargs.pop('password'))
method = getattr(requests, method)
response = method(url, **kwargs)
response.raise_for_status()