Small, fast HTTP client library for Python. Features persistent connections, cache, and Google App Engine support. Originally written by Joe Gregorio, now supported by community.

Overview

Introduction

httplib2 is a comprehensive HTTP client library, httplib2.py supports many features left out of other HTTP libraries.

HTTP and HTTPS

HTTPS support is only available if the socket module was compiled with SSL support.

Keep-Alive

Supports HTTP 1.1 Keep-Alive, keeping the socket open and performing multiple requests over the same connection if possible.

Authentication

The following three types of HTTP Authentication are supported. These can be used over both HTTP and HTTPS.

  • Digest
  • Basic
  • WSSE

Caching

The module can optionally operate with a private cache that understands the Cache-Control: header and uses both the ETag and Last-Modified cache validators.

All Methods

The module can handle any HTTP request method, not just GET and POST.

Redirects

Automatically follows 3XX redirects on GETs.

Compression

Handles both 'deflate' and 'gzip' types of compression.

Lost update support

Automatically adds back ETags into PUT requests to resources we have already cached. This implements Section 3.2 of Detecting the Lost Update Problem Using Unreserved Checkout.

Unit Tested

A large and growing set of unit tests.

Installation

$ pip install httplib2

Usage

A simple retrieval:

import httplib2
h = httplib2.Http(".cache")
(resp_headers, content) = h.request("http://example.org/", "GET")

The 'content' is the content retrieved from the URL. The content is already decompressed or unzipped if necessary.

To PUT some content to a server that uses SSL and Basic authentication:

import httplib2
h = httplib2.Http(".cache")
h.add_credentials('name', 'password')
(resp, content) = h.request("https://example.org/chapter/2",
                            "PUT", body="This is text",
                            headers={'content-type':'text/plain'} )

Use the Cache-Control: header to control how the caching operates.

import httplib2
h = httplib2.Http(".cache")
(resp, content) = h.request("http://bitworking.org/", "GET")
...
(resp, content) = h.request("http://bitworking.org/", "GET",
                            headers={'cache-control':'no-cache'})

The first request will be cached and since this is a request to bitworking.org it will be set to be cached for two hours, because that is how I have my server configured. Any subsequent GET to that URI will return the value from the on-disk cache and no request will be made to the server. You can use the Cache-Control: header to change the caches behavior and in this example the second request adds the Cache-Control: header with a value of 'no-cache' which tells the library that the cached copy must not be used when handling this request.

More example usage can be found at:

Comments
  • Timeout error when using proxy with httplib2

    Timeout error when using proxy with httplib2

    I'm trying to use httplib2 to work with proxy but for some reason socks alwayes None.

    for example the following code :

    import httplib2
    http = httplib2.Http(proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL,myproxy,myPort) )
    resp, content = http.request("http://google.com", "GET")
    print(Resp)
    

    Any idea why ?

    opened by karamjaber 32
  • ca_certs from environment or certifi

    ca_certs from environment or certifi

    This PR is similar to https://github.com/httplib2/httplib2/pull/52 with following differences:

    environment variable "HTTPLIB2_CA_CERTS" also overrides certifi.where()

    I added some unit tests.

    enhancement feature-security 
    opened by dirkboye 21
  • Cleaned-up python 3 proxy support

    Cleaned-up python 3 proxy support

    This is adapapted from #73

    #73 introduced a lot of white-space changes and automated clean-ups which made the patch hard to review.

    It also copy-pasted (!) a socks.py module from SocksiPy.

    This version does not ship a socks module, users that require a proxy will need to install their own socks library (I used PySocks) in addition to httplib2.

    Since the default value for proxy_info is proxy_info_from_environment, this means that without any other changes, upgrading to this version will cause httplib2 to respect HTTP_PROXY / HTTPS_PROXY environment variables.

    Closes #53 Closes #25 Closes #22

    opened by cveilleux 21
  • Getting

    Getting "TypeError: can't concat str to bytes" while using proxy_type=PROXY_TYPE_SOCKS5

    Stacktrace:

    $ C:/Python37/python3.exe c:/Users/myuser/Desktop/r.py
    Traceback (most recent call last):
      File "c:/Users/myuser/Desktop/r.py", line 86, in <module>
        test_sock5_httplib2()
      File "c:/Users/myuser/Desktop/r.py", line 80, in test_sock5_httplib2
        resp, content = http.request("https://somesite.com", "GET")
      File "C:\Python37\lib\site-packages\httplib2\__init__.py", line 1953, in request
        cachekey,
      File "C:\Python37\lib\site-packages\httplib2\__init__.py", line 1618, in _request
        conn, request_uri, method, body, headers
      File "C:\Python37\lib\site-packages\httplib2\__init__.py", line 1524, in _conn_request
        conn.connect()
      File "C:\Python37\lib\site-packages\httplib2\__init__.py", line 1305, in connect
        sock.connect((self.host, self.port))
      File "C:\Python37\lib\site-packages\httplib2\socks.py", line 488, in connect
        self.__negotiatesocks5(destpair[0], destpair[1])
      File "C:\Python37\lib\site-packages\httplib2\socks.py", line 281, in __negotiatesocks5
        + self.__proxy[5]
    TypeError: can't concat str to bytes
    

    System Detail:

    >>> import sys
    >>> sys.version
    '3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]'
    >>> import httplib2
    >>> httplib2.__version__
    '0.13.1'
    >>> 
    

    Source code(r.py):

    def test_sock5_httplib2():
        from httplib2 import Http, socks, ProxyInfo
    
        proxy = ProxyInfo(proxy_type=socks.PROXY_TYPE_SOCKS5,
                                       proxy_host="IP",
                                       proxy_port=1080,
                                       proxy_user="user",
                                       proxy_pass="password",
                                       proxy_rdns=False)
    
        http = Http(proxy_info = proxy)
        # http = Http()
        resp, content = http.request("https://somesite.com", "GET")
        print(resp.status)
    
    if __name__ == "__main__":
        test_sock5_httplib2()
    
    opened by mahirchavda 16
  • add support for password protected certificate files

    add support for password protected certificate files

    This should improve the security by protecting private cert key with password when using httplib2 with client certificates to initiate mutual TLS connection. See #142

    This adds an optional "password" arg to add_certificate() function. If "password" is provided then "key" points to password encrypted cert file.

    This may break unit-tests due to changes to KeyCerts class. I'm still trying to figure out how to run tests properly. I will provide an update after I resolve those issues.

    opened by kkoshelev-g 16
  • Support pyparsing v3 (AttributeError downcaseTokens)

    Support pyparsing v3 (AttributeError downcaseTokens)

    There appears to be a use of a discontinued feature from the pyparsing library:

    Traceback (most recent call last):
    [...]
      File "/usr/local/lib/python3.9/dist-packages/httplib2/__init__.py", line 52, in <module>
        from . import auth
      File "/usr/local/lib/python3.9/dist-packages/httplib2/auth.py", line 20, in <module>
        auth_param_name = token.copy().setName("auth-param-name").addParseAction(pp.downcaseTokens)
    AttributeError: module 'pyparsing' has no attribute 'downcaseTokens'
    
    enhancement 
    opened by mborsetti 14
  • httplib2.RedirectMissingLocation error with GCloud Upload

    httplib2.RedirectMissingLocation error with GCloud Upload

    See: https://stackoverflow.com/questions/59815620/gcloud-upload-httplib2-redirectmissinglocation-redirected-but-the-response-is-m

    I'm assuming this is a strict change for the better but what are the code changes required to prevent this exception from being thrown?

    opened by neilodonuts 14
  • Catch socket timeouts and clear dead connection (refs #18)

    Catch socket timeouts and clear dead connection (refs #18)

    Re #18 , this MR catches a socket timeout in the request and clears the cached connection instance. This allows for the following request to establish a new connection instead of hitting the dead connection.

    Not ready for merge yet. While manual reproduction mentioned in #18 now works correctly with this change, the tests are not properly failing when the patch is not applied. I am looking for some feedback to understand how to adjust the test to behave the same way a normal production usage would function with the Http class.

    opened by justinfx 13
  • test_noproxy_star fails

    test_noproxy_star fails

    test_noproxy_star fails on both Python 2.7 and 3.6 here:

    =================================== FAILURES ===================================
    ______________________________ test_noproxy_star _______________________________
    tests/test_proxy.py:76: in test_noproxy_star
        assert not pi.applies_to(host)
    E   AssertionError: assert not True
    E    +  where True = <bound method ProxyInfo.applies_to of <ProxyInfo type=3 host:port=myproxy.example.com:80 rdns=True user=None headers=None>>('169.254.38.192')
    E    +    where <bound method ProxyInfo.applies_to of <ProxyInfo type=3 host:port=myproxy.example.com:80 rdns=True user=None headers=None>> = <ProxyInfo type=3 host:port=myproxy.example.com:80 rdns=True user=None headers=None>.applies_to
    
    opened by felixonmars 13
  • Python3 v0.11.0 HTTPConnectionWithTimeout AttributeError proxy_info

    Python3 v0.11.0 HTTPConnectionWithTimeout AttributeError proxy_info

    When proxy_info=None, HTTPConnectionWithTimeout's constructor will not set proxy_info to anything, which therefore triggers an AttributeError when connect is called.

    For example, this test script:

    import httplib2
    connection = httplib2.HTTPConnectionWithTimeout('www.example.com', 80)
    connection.request('GET', '/')
    connection.close()
    

    Results in:

    (venv) C02VP0WSHTD8:httplib2_test2 jryan$ python3 test.py
      Traceback (most recent call last):
        File "test.py", line 4, in <module>
          connection.request('GET', '/')
        File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
          self._send_request(method, url, body, headers, encode_chunked)
        File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
          self.endheaders(body, encode_chunked=encode_chunked)
        File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
          self._send_output(message_body, encode_chunked=encode_chunked)
        File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
          self.send(msg)
        File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
          self.connect()
        File "/Users/jryan/Documents/httplib2_test2/httplib2/python3/httplib2/__init__.py", line 897, in connect
          if self.proxy_info and socks is None:
      AttributeError: 'HTTPConnectionWithTimeout' object has no attribute 'proxy_info'
    
    bug 
    opened by germanjoey 13
  • Python 3 trove classifier now missing from PyPI page

    Python 3 trove classifier now missing from PyPI page

    Originally posted as: https://github.com/jcgregorio/httplib2/issues/333

    The lower left of https://pypi.org/project/httplib2/0.9.2 contains the Programming Language :: Python :: 3 trove classifier but https://pypi.org/project/httplib2 does not. This means that scripts can no longer automatically determine the Python 3 compatibility of httplib2.

    help wanted 
    opened by cclauss 13
  • httplib2 report ServerNotFoundError when use a proxy

    httplib2 report ServerNotFoundError when use a proxy

    I found this issue when use tool add-apt-repository:

    ❯ sudo add-apt-repository ppa:ondrej/php -y
    [sudo] password for nidb:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1363, in _conn_request
        conn.connect()
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1139, in connect
        address_info = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
      File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
        for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    socket.gaierror: [Errno -2] Name or service not known
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/bin/add-apt-repository", line 364, in <module>
        sys.exit(0 if addaptrepo.main() else 1)
      File "/usr/bin/add-apt-repository", line 347, in main
        shortcut = handler(source, **shortcut_params)
      File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler
        return handler(shortcut, **kwargs)
      File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 82, in __init__
        if self.lpppa.publish_debug_symbols:
      File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 120, in lpppa
        self._lpppa = self.lpteam.getPPAByName(name=self.ppaname)
      File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 107, in lpteam
        self._lpteam = self.lp.people(self.teamname)
      File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 98, in lp
        self._lp = login_func("%s.%s" % (self.__module__, self.__class__.__name__),
      File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 494, in login_anonymously
        return cls(
      File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 230, in __init__
        super(Launchpad, self).__init__(
      File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 472, in __init__
        self._wadl = self._browser.get_wadl_application(self._root_uri)
      File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 447, in get_wadl_application
        response, content = self._request(url, media_type=wadl_type)
      File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 389, in _request
        response, content = self._request_and_retry(
      File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 359, in _request_and_retry
        response, content = self._connection.request(
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1725, in request
        (response, content) = self._request(
      File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 144, in _request
        response, content = super(LaunchpadOAuthAwareHttp, self)._request(
      File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 184, in _request
        return super(RestfulHttp, self)._request(
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1441, in _request
        (response, content) = self._conn_request(conn, request_uri, method, body, headers)
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1370, in _conn_request
        raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
    httplib2.error.ServerNotFoundError: Unable to find the server at api.launchpad.net
    

    I notice httplib2 say "Unable to find the server at api.launchpad.net" so I try nslookup and curl but they work fine.

    Then I use python REPL and try request http://cn.bing.com use httplib2, and.... httplib2 say ServerNotFound

    Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import httplib2
    >>> h = httplib2.Http(".cache")
    >>> (header, content) = h.request("http://cn.bing.com", "GET")
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1363, in _conn_request
        conn.connect()
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1024, in connect
        for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
      File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
        for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    socket.gaierror: [Errno -2] Name or service not known
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1725, in request
        (response, content) = self._request(
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1441, in _request
        (response, content) = self._conn_request(conn, request_uri, method, body, headers)
      File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1370, in _conn_request
        raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
    httplib2.error.ServerNotFoundError: Unable to find the server at cn.bing.com
    >>>
    

    image

    Then I disable my proxy by unset HTTP_PROXY and try again, and request has no error.

    opened by nidbCN 1
  • Some HTTP requests fail if

    Some HTTP requests fail if "uri"type is "bytes"

    File "/snap/google-cloud-sdk/current/lib/third_party/httplib2/python3/httplib2/init.py", line 1776, in request uri = uri.replace(" ", "%20").replace("\r", "%0D").replace("\n", "%0A") TypeError: a bytes-like object is required, not 'str'

    Particularly, "google-cloud-sdk" using your lib, passes bytes in some occurrences.

    This could be simply be fixed like this (nearby the line 1533):

    if isinstance(uri, bytes):
        uri = uri.decode("utf-8")
    

    just before uri = uri.replace.....

    opened by zoosmand 0
  • 0.20.4 test failure: test_client_cert_password_verified

    0.20.4 test failure: test_client_cert_password_verified

    This is on Void Linux:

    /usr/lib/python3.10/site-packages/cryptography/x509/base.py:531: in load_pem_x509_certificate
        return rust_x509.load_pem_x509_certificate(data)
    E   ValueError: Unable to load PEM file. See https://cryptography.io/en/latest/faq.html#why-can-t-i-import-my-pem-file for more details. InvalidData(InvalidByte(4, 45))
    

    Am I missing some check dependency, or is this error expected? The pr is located at https://github.com/void-linux/void-packages/pull/35376/commits/0835a7a533a1d32b0560051f0aff83f40fafb3f2 Full error:

    =================================== FAILURES ===================================
    ______________________ test_client_cert_password_verified ______________________
    tests/test_https.py:151: in test_client_cert_password_verified
        expect_serial = tests.x509_serial(tests.CLIENT_ENCRYPTED_PEM) if tests.x509 else 16332984194609126128
            cert_log   = [{'issuer': ((('countryName', 'ZZ'),), (('stateOrProvinceName', '.'),), (('localityName', '.'),), (('organizationName'...tAfter': 'Oct  1 23:57:26 2031 GMT', 'notBefore': 'Oct  3 23:57:26 2021 GMT', 'serialNumber': 'E2AA6A96D1BF1AF0', ...}]
            handler    = <function test_client_cert_password_verified.<locals>.handler at 0x7f179a0b5480>
            http       = <httplib2.Http object at 0x7f179a0f8910>
            setup_tls  = <function test_client_cert_password_verified.<locals>.setup_tls at 0x7f179a0b4dc0>
            uri        = 'https://localhost:44255/'
            uri_parsed = ParseResult(scheme='https', netloc='localhost:44255', path='/', params='', query='', fragment='')
    tests/__init__.py:786: in x509_serial
        cert = x509.load_pem_x509_certificate(pem)
            f          = <_io.BufferedReader name='/builddir/httplib2-0.20.4/tests/tls/client_encrypted.pem'>
            path       = '/builddir/httplib2-0.20.4/tests/tls/client_encrypted.pem'
            pem        = b'serial=E2AA6A96D1BF1AF0\nSHA1 Fingerprint=FB:42:16:53:02:8D:EA:F9:66:DB:BD:88:37:E1:93:7E:97:21:29:23\n-----BEGIN CE...LOQ4D+jK8/fcV9bhBuH\nLzBJ4gtPwUnvYqsaiIAeGi2EVllW0Ka+aTTzM1Yascl2q9WROvutAT0zz0M6smpO\n-----END RSA PRIVATE KEY-----\n'
    /usr/lib/python3.10/site-packages/cryptography/x509/base.py:531: in load_pem_x509_certificate
        return rust_x509.load_pem_x509_certificate(data)
    E   ValueError: Unable to load PEM file. See https://cryptography.io/en/latest/faq.html#why-can-t-i-import-my-pem-file for more details. InvalidData(InvalidByte(4, 45))
            backend    = None
            data       = b'serial=E2AA6A96D1BF1AF0\nSHA1 Fingerprint=FB:42:16:53:02:8D:EA:F9:66:DB:BD:88:37:E1:93:7E:97:21:29:23\n-----BEGIN CE...LOQ4D+jK8/fcV9bhBuH\nLzBJ4gtPwUnvYqsaiIAeGi2EVllW0Ka+aTTzM1Yascl2q9WROvutAT0zz0M6smpO\n-----END RSA PRIVATE KEY-----\n'
    

    Thanks.

    opened by dkwo 1
  • `test_connection_close` fails on Apple Silicon

    `test_connection_close` fails on Apple Silicon

    I'm building beancount with Nix on a Macbook Air M1, and while running through the tests of httplib2, I get tests/test_other.py::test_connection_close FAILED. All other tests either pass or are skipped. The error I get is:

    =================================== FAILURES ===================================
    ____________________________ test_connection_close _____________________________
    tests/test_other.py:163: in test_connection_close
        http.request(uri, "GET")  # conn2 req1
            c          = <httplib2.HTTPConnectionWithTimeout object at 0x107340280>
            g          = [1, 2]
            handler    = <function test_connection_close.<locals>.handler at 0x107209430>
            http       = <httplib2.Http object at 0x107340eb0>
            uri        = 'http://localhost:51450/'
    /nix/store/asvvc5cf87lypq4bnsc7bzlyi8lpdk3x-python3.9-httplib2-0.20.3/lib/python3.9/site-packages/httplib2/__init__.py:1721: in request
        (response, content) = self._request(
            authority  = 'localhost:51450'
            body       = None
            cached_value = None
            cachekey   = None
            cc         = {}
            conn       = <httplib2.HTTPConnectionWithTimeout object at 0x107340280>
            conn_key   = 'http:localhost:51450'
            connection_type = None
            defrag_uri = 'http://localhost:51450/'
            headers    = {'accept-encoding': 'gzip, deflate', 'user-agent': 'Python-httplib2/0.20.3 (gzip)'}
            info       = <email.message.Message object at 0x107340940>
            is_timeout = False
            method     = 'GET'
            redirections = 5
            request_uri = '/'
            scheme     = 'http'
            self       = <httplib2.Http object at 0x107340eb0>
            uri        = 'http://localhost:51450/'
    /nix/store/asvvc5cf87lypq4bnsc7bzlyi8lpdk3x-python3.9-httplib2-0.20.3/lib/python3.9/site-packages/httplib2/__init__.py:1441: in _request
        (response, content) = self._conn_request(conn, request_uri, method, body, headers)
            absolute_uri = 'http://localhost:51450/'
            auth       = None
            auths      = []
            body       = None
            cachekey   = None
            conn       = <httplib2.HTTPConnectionWithTimeout object at 0x107340280>
            headers    = {'accept-encoding': 'gzip, deflate', 'user-agent': 'Python-httplib2/0.20.3 (gzip)'}
            host       = 'localhost:51450'
            method     = 'GET'
            redirections = 5
            request_uri = '/'
            self       = <httplib2.Http object at 0x107340eb0>
    /nix/store/asvvc5cf87lypq4bnsc7bzlyi8lpdk3x-python3.9-httplib2-0.20.3/lib/python3.9/site-packages/httplib2/__init__.py:1393: in _conn_request
        response = conn.getresponse()
            body       = None
            conn       = <httplib2.HTTPConnectionWithTimeout object at 0x107340280>
            headers    = {'accept-encoding': 'gzip, deflate', 'user-agent': 'Python-httplib2/0.20.3 (gzip)'}
            i          = 1
            method     = 'GET'
            request_uri = '/'
            seen_bad_status_line = False
            self       = <httplib2.Http object at 0x107340eb0>
    /nix/store/llqjaw6wamkksidg7i0l9kjdaggsawjj-python3-3.9.10/lib/python3.9/http/client.py:1377: in getresponse
        response.begin()
            response   = <http.client.HTTPResponse object at 0x107340fd0>
            self       = <httplib2.HTTPConnectionWithTimeout object at 0x107340280>
    /nix/store/llqjaw6wamkksidg7i0l9kjdaggsawjj-python3-3.9.10/lib/python3.9/http/client.py:320: in begin
        version, status, reason = self._read_status()
            self       = <http.client.HTTPResponse object at 0x107340fd0>
    /nix/store/llqjaw6wamkksidg7i0l9kjdaggsawjj-python3-3.9.10/lib/python3.9/http/client.py:281: in _read_status
        line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
            self       = <http.client.HTTPResponse object at 0x107340fd0>
    /nix/store/llqjaw6wamkksidg7i0l9kjdaggsawjj-python3-3.9.10/lib/python3.9/socket.py:704: in readinto
        return self._sock.recv_into(b)
    E   ConnectionResetError: [Errno 54] Connection reset by peer
            b          = <memory at 0x107259d00>
            self       = <socket.SocketIO object at 0x107340760>
    

    As you can see, the version hosted on nixpkgs-unstable is 0.20.3, so I don't know if that is relevant.

    opened by kmaasrud 0
  • How to setup proxyInfo with Luminati (https://brightdata.com/)

    How to setup proxyInfo with Luminati (https://brightdata.com/)

    This code below is not working

    proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL,
                                    'zproxy.lum-superproxy.io', 22225,
                                    proxy_user='user',
                                    proxy_pass='pass')
    client = httplib2.Http(proxy_info=proxy_info)
    
    response, body = client.request('http://lumtest.com/myip.json')
    print('response', response, body)
    
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 993, in send
        self.sock.sendall(data)
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/socks.py", line 182, in sendall
        content = self.__rewriteproxy(content)
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/socks.py", line 191, in __rewriteproxy
        hdrs = header.split("\r\n")
    TypeError: a bytes-like object is required, not 'str'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/macbookpro/PycharmProjects/storedbservice/Public.py", line 27, in <module>
        response, body = client.request('http://lumtest.com/myip.json')
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/__init__.py", line 1994, in request
        cachekey,
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/__init__.py", line 1651, in _request
        conn, request_uri, method, body, headers
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/__init__.py", line 1558, in _conn_request
        conn.request(method, request_uri, body, headers)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1277, in request
        self._send_request(method, url, body, headers, encode_chunked)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1323, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1272, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1032, in _send_output
        self.send(msg)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 997, in send
        self.sock.sendall(d)
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/socks.py", line 182, in sendall
        content = self.__rewriteproxy(content)
      File "/Users/macbookpro/Desktop/Dev/python_env/local_env/lib/python3.7/site-packages/httplib2/socks.py", line 191, in __rewriteproxy
        hdrs = header.split("\r\n")
    AttributeError: 'int' object has no attribute 'split'
    

    Thanks

    opened by workingxx92 4
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Jan 1, 2023
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.

urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many

urllib3 3.2k Dec 29, 2022
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.

urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many

urllib3 3.2k Jan 2, 2023
EasyRequests is a minimalistic HTTP-Request Library that wraps aiohttp and asyncio in a small package that allows for sequential, parallel or even single requests

EasyRequests EasyRequests is a minimalistic HTTP-Request Library that wraps aiohttp and asyncio in a small package that allows for sequential, paralle

Avi 1 Jan 27, 2022
Asynchronous HTTP client/server framework for asyncio and Python

Async http client/server framework Key Features Supports both client and server side of HTTP protocol. Supports both client and server Web-Sockets out

aio-libs 13.1k Jan 1, 2023
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie

HTTP Prompt HTTP Prompt is an interactive command-line HTTP client featuring autocomplete and syntax highlighting, built on HTTPie and prompt_toolkit.

HTTPie 8.6k Dec 31, 2022
A next generation HTTP client for Python. 🦋

HTTPX - A next-generation HTTP client for Python. HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support

Encode 9.8k Jan 5, 2023
Python requests like API built on top of Twisted's HTTP client.

treq: High-level Twisted HTTP Client API treq is an HTTP library inspired by requests but written on top of Twisted's Agents. It provides a simple, hi

Twisted Matrix Labs 553 Dec 18, 2022
Aiosonic - lightweight Python asyncio http client

aiosonic - lightweight Python asyncio http client Very fast, lightweight Python asyncio http client Here is some documentation. There is a performance

Johanderson Mogollon 93 Jan 6, 2023
A minimal HTTP client. ⚙️

HTTP Core Do one thing, and do it well. The HTTP Core package provides a minimal low-level HTTP client, which does one thing only. Sending HTTP reques

Encode 306 Dec 27, 2022
Fast HTTP parser

httptools is a Python binding for the nodejs HTTP parser. The package is available on PyPI: pip install httptools. APIs httptools contains two classes

magicstack 1.1k Jan 7, 2023
A modern/fast python SOAP client based on lxml / requests

Zeep: Python SOAP client A fast and modern Python SOAP client Highlights: Compatible with Python 3.6, 3.7, 3.8 and PyPy Build on top of lxml and reque

Michael van Tellingen 1.7k Jan 1, 2023
A simple, yet elegant HTTP library.

Requests Requests is a simple, yet elegant HTTP library. >>> import requests >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass')

Python Software Foundation 48.8k Jan 5, 2023
🔄 🌐 Handle thousands of HTTP requests, disk writes, and other I/O-bound tasks simultaneously with Python's quintessential async libraries.

?? ?? Handle thousands of HTTP requests, disk writes, and other I/O-bound tasks simultaneously with Python's quintessential async libraries.

Hackers and Slackers 15 Dec 12, 2022
A Python obfuscator using HTTP Requests and Hastebin.

?? Jawbreaker ?? Jawbreaker is a Python obfuscator written in Python3, using double encoding in base16, base32, base64, HTTP requests and a Hastebin-l

Billy 50 Sep 28, 2022
Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once

pathprober Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once. Purpose Brute-forcing webs

NFA 41 Jul 6, 2022
Asynchronous Python HTTP Requests for Humans using Futures

Asynchronous Python HTTP Requests for Humans Small add-on for the python requests http library. Makes use of python 3.2's concurrent.futures or the ba

Ross McFarland 2k Dec 30, 2022
HTTP/2 for Python.

Hyper: HTTP/2 Client for Python This project is no longer maintained! Please use an alternative, such as HTTPX or others. We will not publish further

Hyper 1k Dec 23, 2022
HTTP request/response parser for python in C

http-parser HTTP request/response parser for Python compatible with Python 2.x (>=2.7), Python 3 and Pypy. If possible a C parser based on http-parser

Benoit Chesneau 334 Dec 24, 2022