Browse Source

Add verify_ssl option to HTTPClient

tags/nilmdb-1.9.5
Jim Paris 8 years ago
parent
commit
abe431c663
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      nilmdb/client/httpclient.py

+ 4
- 2
nilmdb/client/httpclient.py View File

@@ -9,7 +9,7 @@ import requests

class HTTPClient(object):
"""Class to manage and perform HTTP requests from the client"""
def __init__(self, baseurl = "", post_json = False):
def __init__(self, baseurl = "", post_json = False, verify_ssl = True):
"""If baseurl is supplied, all other functions that take
a URL can be given a relative URL instead."""
# Verify / clean up URL
@@ -19,6 +19,7 @@ class HTTPClient(object):
self.baseurl = reparsed.rstrip('/') + '/'

# Build Requests session object, enable SSL verification
self.verify_ssl = verify_ssl
self.session = requests.Session()
self.session.verify = True

@@ -67,7 +68,8 @@ class HTTPClient(object):
params = query_data,
data = body_data,
stream = stream,
headers = headers)
headers = headers,
verify = self.verify_ssl)
except requests.RequestException as e:
raise ServerError(status = "502 Error", url = url,
message = str(e.message))


Loading…
Cancel
Save