diff --git a/pyes/connection_http.py b/pyes/connection_http.py index a0ff50f0..0c9cac63 100644 --- a/pyes/connection_http.py +++ b/pyes/connection_http.py @@ -29,7 +29,7 @@ class ClientTransport(object): """Encapsulation of a client session.""" - def __init__(self, server, framed_transport, timeout, recycle, basic_auth): + def __init__(self, server, framed_transport, timeout, recycle, basic_auth=None): self.connection_type, self.host, self.port = server self.timeout = timeout self.headers = {} @@ -53,7 +53,8 @@ def execute(self, request): """ headers = self.headers.copy() headers.update(request.headers) - response = requests.request(method=Method._VALUES_TO_NAMES[request.method], + s = requests.session() + response = s.request(method=Method._VALUES_TO_NAMES[request.method], url="http://%s:%s%s" % (self.host, self.port, request.uri), params=request.parameters, data=request.body, headers=request.headers) return RestResponse(status=response.status_code, body=response.content, headers=response.headers)