Merge "close http connections"
This commit is contained in:
commit
0042d2de86
|
@ -0,0 +1,27 @@
|
||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright 2013 OpenStack, LLC
|
||||||
|
# Copyright 2013 Citrix Systems, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import httplib2
|
||||||
|
|
||||||
|
|
||||||
|
class ClosingHttp(httplib2.Http):
|
||||||
|
def request(self, *args, **kwargs):
|
||||||
|
original_headers = kwargs.get('headers', {})
|
||||||
|
new_headers = dict(original_headers, connection='close')
|
||||||
|
new_kwargs = dict(kwargs, headers=new_headers)
|
||||||
|
return super(ClosingHttp, self).request(*args, **new_kwargs)
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import hashlib
|
import hashlib
|
||||||
import httplib2
|
|
||||||
import json
|
import json
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest import exceptions
|
from tempest import exceptions
|
||||||
from tempest.openstack.common import log as logging
|
from tempest.openstack.common import log as logging
|
||||||
from tempest.services.compute.xml.common import xml_to_json
|
from tempest.services.compute.xml.common import xml_to_json
|
||||||
|
@ -64,7 +64,8 @@ class RestClient(object):
|
||||||
'retry-after', 'server',
|
'retry-after', 'server',
|
||||||
'vary', 'www-authenticate'))
|
'vary', 'www-authenticate'))
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
|
|
||||||
def _set_auth(self):
|
def _set_auth(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import httplib2
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClient
|
from tempest.common.rest_client import RestClient
|
||||||
from tempest import exceptions
|
from tempest import exceptions
|
||||||
|
|
||||||
|
@ -260,7 +260,8 @@ class TokenClientJSON(RestClient):
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = {}
|
headers = {}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
import httplib2
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClientXML
|
from tempest.common.rest_client import RestClientXML
|
||||||
from tempest.services.compute.xml.common import Document
|
from tempest.services.compute.xml.common import Document
|
||||||
from tempest.services.compute.xml.common import Element
|
from tempest.services.compute.xml.common import Element
|
||||||
|
@ -50,7 +50,8 @@ class EndPointClientXML(RestClientXML):
|
||||||
def request(self, method, url, headers=None, body=None, wait=None):
|
def request(self, method, url, headers=None, body=None, wait=None):
|
||||||
"""Overriding the existing HTTP request in super class RestClient."""
|
"""Overriding the existing HTTP request in super class RestClient."""
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
self._set_auth()
|
self._set_auth()
|
||||||
self.base_url = self.base_url.replace(
|
self.base_url = self.base_url.replace(
|
||||||
urlparse.urlparse(self.base_url).path, "/v3")
|
urlparse.urlparse(self.base_url).path, "/v3")
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
import httplib2
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClientXML
|
from tempest.common.rest_client import RestClientXML
|
||||||
from tempest.services.compute.xml.common import Document
|
from tempest.services.compute.xml.common import Document
|
||||||
from tempest.services.compute.xml.common import Element
|
from tempest.services.compute.xml.common import Element
|
||||||
|
@ -51,7 +51,8 @@ class PolicyClientXML(RestClientXML):
|
||||||
def request(self, method, url, headers=None, body=None, wait=None):
|
def request(self, method, url, headers=None, body=None, wait=None):
|
||||||
"""Overriding the existing HTTP request in super class RestClient."""
|
"""Overriding the existing HTTP request in super class RestClient."""
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
self._set_auth()
|
self._set_auth()
|
||||||
self.base_url = self.base_url.replace(urlparse(self.base_url).path,
|
self.base_url = self.base_url.replace(urlparse(self.base_url).path,
|
||||||
"/v3")
|
"/v3")
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import httplib2
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClientXML
|
from tempest.common.rest_client import RestClientXML
|
||||||
from tempest import exceptions
|
from tempest import exceptions
|
||||||
from tempest.services.compute.xml.common import Document
|
from tempest.services.compute.xml.common import Document
|
||||||
|
@ -275,7 +275,8 @@ class TokenClientXML(RestClientXML):
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = {}
|
headers = {}
|
||||||
self._log_request(method, url, headers, body)
|
self._log_request(method, url, headers, body)
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import httplib2
|
|
||||||
import json
|
import json
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClient
|
from tempest.common.rest_client import RestClient
|
||||||
from tempest import exceptions
|
from tempest import exceptions
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class AccountClientCustomizedHeader(RestClient):
|
||||||
|
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
self.http_obj = httplib2.Http()
|
self.http_obj = http.ClosingHttp()
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = {}
|
headers = {}
|
||||||
if self.base_url is None:
|
if self.base_url is None:
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import httplib2
|
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
from tempest.common import http
|
||||||
from tempest.common.rest_client import RestClient
|
from tempest.common.rest_client import RestClient
|
||||||
from tempest import exceptions
|
from tempest import exceptions
|
||||||
|
|
||||||
|
@ -162,7 +162,8 @@ class ObjectClientCustomizedHeader(RestClient):
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
dscv = self.config.identity.disable_ssl_certificate_validation
|
dscv = self.config.identity.disable_ssl_certificate_validation
|
||||||
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
|
self.http_obj = http.ClosingHttp(
|
||||||
|
disable_ssl_certificate_validation=dscv)
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = {}
|
headers = {}
|
||||||
if self.base_url is None:
|
if self.base_url is None:
|
||||||
|
|
Loading…
Reference in New Issue