Skip to main content

A wrapper over urllib3 that matches httplib2's interface

Project description

Build Status Coverage Status PyPI Version

httplib2shim is a wrapper over httplib2 that uses urllib3 to perform HTTP requests. This library is intended to help existing legacy libraries (and their users) to migrate away from httplib2. It is not intended to be a general purpose replacement for httplib2. It does not support every feature and edge case for httplib2, although contributions are welcome in order to help us cover these cases.

Presently, httplib2shim passes the test suite for httplib2. A few non-applicable tests were disabled, and it’s very possible that the tests do not account for behavior that is depended on by clients.

Usage

It’s recommended to install urllib3[secure] before installing httplib2shim:

pip install urllib3[secure] httplib2shim

Usage is straightforward. You can substitute httplib2shim.Http anywhere httplib2.Http is used:

import httplib2shim
from oauth2client.client import GoogleCredentials


credentials = GoogleCredentials.get_application_default()
http = httplib2shim.Http()
credentials.authorize(http)

# http is now authorized with OAuth2 credentials and uses urllib3 under
# the covers.

Alternatively, if you do not control the construction of the Http object, you can use httplib2shim.patch() to monkey-patch the httplib2.Http class to point to httplib2shim.Http():

import httplib2shim
httplib2shim.patch()

from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials

credentials = GoogleCredentials.get_application_default()

# build constructs its own httplib2.Http instance.
service = build('compute', 'v1', credentials=credentials)

# service.http is now a httplib2shim.Http object.

Unsupported Features

  • Arguments to the Http constructor will be accepted, but may not make a difference. For instance, ca_certs will have no effect. Instead, pass a urllib3.Pool instance http = httplib2shim.Http(pool=my_pool).

  • Http.add_certificate is a no-op and will warn.

  • Probably others, pull requests are welcome to complete the functionality.

Contributing changes

Licensing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httplib2shim-0.0.2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

httplib2shim-0.0.2-py2.py3-none-any.whl (20.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file httplib2shim-0.0.2.tar.gz.

File metadata

File hashes

Hashes for httplib2shim-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c3f364fb6a84b0f51af358175d3fa257d45ba1210dbcdfc7f2d9fabbca012374
MD5 86db728910f29097bbf348ba09cfe815
BLAKE2b-256 e8e7793f053373dbbde09fb05bea276afdc7253f535e0ee13b89bde4ed1fe375

See more details on using hashes here.

File details

Details for the file httplib2shim-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for httplib2shim-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b26d57cbb68065cfabf95f50361c87bf97c01bd3e01e671a51409840954187c8
MD5 2cb645789fec44337a805fd4edeada33
BLAKE2b-256 969102c3abcf6bb9819aba457b39b993529521cc6924d25b0c4f463c6cc4fceb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page