Replace old httpclient with requests
This review implements blueprint python-request and replaces the old
http client implementation in favor of a new one based on
python-requests.
Major changes:
* raw_request and json_request removed since everything is now being
handled by the same method "_request"
* New methods that match HTTP's methods were added:
- get
- put
- post
- head
- patch
- delete
* Content-Type is now being "inferred" based on the data being sent:
- if it is file-like object it chunks the request
- if it is a python type not instance of basestring then it'll try
to serialize it to json
- Every other case will keep the incoming content-type and will send
the data as is.
* Glanceclient's HTTPSConnection implementation will be used if
no-compression flag is set to True.
Co-Author: Flavio Percoco<flaper87@gmail.com>
Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
This commit is contained in:
@@ -13,10 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from glanceclient.common import http
|
||||
from glanceclient.common.http import HTTPClient
|
||||
from glanceclient.common import utils
|
||||
from glanceclient.v1 import image_members
|
||||
from glanceclient.v1 import images
|
||||
from glanceclient.v1.image_members import ImageMemberManager
|
||||
from glanceclient.v1.images import ImageManager
|
||||
|
||||
|
||||
class Client(object):
|
||||
@@ -31,7 +31,7 @@ class Client(object):
|
||||
|
||||
def __init__(self, endpoint, *args, **kwargs):
|
||||
"""Initialize a new client for the Images v1 API."""
|
||||
self.http_client = http.HTTPClient(utils.strip_version(endpoint),
|
||||
*args, **kwargs)
|
||||
self.images = images.ImageManager(self.http_client)
|
||||
self.image_members = image_members.ImageMemberManager(self.http_client)
|
||||
self.http_client = HTTPClient(utils.strip_version(endpoint),
|
||||
*args, **kwargs)
|
||||
self.images = ImageManager(self.http_client)
|
||||
self.image_members = ImageMemberManager(self.http_client)
|
||||
|
||||
Reference in New Issue
Block a user