summaryrefslogtreecommitdiff
path: root/src/caas/services/httpclient.py
blob: ad8270bbd472baa2e5722faf4cf9cec1e6747321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from requests.auth import HTTPBasicAuth


class HttpClient(object):
    def __init__(self):
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        self.session = requests.Session()

    def post(self, url, username, password, data = None, headers = {}, timeout = 60):
        resp = self.session.post(url = url,
                                 auth = HTTPBasicAuth(username, password),
                                 json = data,
                                 headers = headers,
                                 timeout = timeout,
                                 verify = False)
        return resp