Commit aa74e7e2 authored by Sigmund Augdal's avatar Sigmund Augdal

Fix http-keepalive in odata library

Create a session in the requests library for each odata client and use that for requests
parent dfec91ad
...@@ -63,6 +63,7 @@ class Client(object): ...@@ -63,6 +63,7 @@ class Client(object):
def __init__(self, baseurl, username, password): def __init__(self, baseurl, username, password):
self.baseurl = baseurl self.baseurl = baseurl
self.auth = HTTPBasicAuth(username, password) self.auth = HTTPBasicAuth(username, password)
self.session = requests.Session()
def _format_url(self, resource, query=None, args=None, subresource=None): def _format_url(self, resource, query=None, args=None, subresource=None):
url = self.baseurl url = self.baseurl
...@@ -85,7 +86,7 @@ class Client(object): ...@@ -85,7 +86,7 @@ class Client(object):
headers = {} headers = {}
if reqdata: if reqdata:
headers["content-type"] = "application/atom+xml;type=entry" headers["content-type"] = "application/atom+xml;type=entry"
resp = requests.request(method, url, data=reqdata, headers=headers, auth=self.auth, verify=False) resp = self.session.request(method, url, data=reqdata, headers=headers, auth=self.auth, verify=False)
data = resp.content data = resp.content
if not data: if not data:
return None return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment