Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Capitalize Hip
Browse files Browse the repository at this point in the history
The module should be left as `hip`, but the project itself is named
`Hip`.
  • Loading branch information
pquentin committed Dec 3, 2019
1 parent b3165ff commit 47395cb
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[metadata]
name = hip
name = Hip
description = HTTP library with thread-safe connection pooling, file post, and more.
long_description = file: README.rst, CHANGES.rst
keywords = urllib, httplib, threadsafe, filepost, http, https, ssl, pooling
Expand Down
6 changes: 3 additions & 3 deletions src/hip/__init__.py
@@ -1,5 +1,5 @@
"""
hip - Thread-safe connection pooling and re-using.
Hip - Thread-safe connection pooling and re-using.
"""
from __future__ import absolute_import
import warnings
Expand Down Expand Up @@ -77,7 +77,7 @@ def add_stderr_logger(level=logging.DEBUG):
Returns the handler after adding it.
"""
# This method needs to be in this __init__.py to get the __name__ correct
# even if hip is vendored within another package.
# even if Hip is vendored within another package.
logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s"))
Expand Down Expand Up @@ -106,6 +106,6 @@ def add_stderr_logger(level=logging.DEBUG):

def disable_warnings(category=exceptions.HTTPWarning):
"""
Helper for quickly disabling all hip warnings.
Helper for quickly disabling all Hip warnings.
"""
warnings.simplefilter("ignore", category)
6 changes: 3 additions & 3 deletions src/hip/_async/connection.py
Expand Up @@ -119,7 +119,7 @@ def _read_readable(readable):
# XX this should return an async iterator
def _make_body_iterable(body):
"""
This function turns all possible body types that hip supports into an
This function turns all possible body types that Hip supports into an
iterable of bytes. The goal is to expose a uniform structure to request
bodies so that they all appear to be identical to the low-level code.
Expand Down Expand Up @@ -195,7 +195,7 @@ def all_pieces_iter():

def _response_from_h11(h11_response, body_object):
"""
Given a h11 Response object, build a hip response object and return it.
Given a h11 Response object, build a Hip response object and return it.
"""
if bytes(h11_response.http_version) not in _SUPPORTED_VERSIONS:
raise BadVersionError(h11_response.http_version)
Expand All @@ -212,7 +212,7 @@ def _response_from_h11(h11_response, body_object):

def _build_tunnel_request(host, port, headers):
"""
Builds a hip Request object that is set up correctly to request a proxy
Builds a Hip Request object that is set up correctly to request a proxy
to establish a TCP tunnel to the remote host.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/hip/_async/connectionpool.py
Expand Up @@ -93,7 +93,7 @@ def _build_context(
ssl_version,
):
"""
Creates a hip context suitable for a given request based on a
Creates a Hip context suitable for a given request based on a
collection of possible properties of that context.
"""
if context is None:
Expand Down
4 changes: 2 additions & 2 deletions src/hip/_async/response.py
Expand Up @@ -243,7 +243,7 @@ def release_conn(self):

@property
def data(self):
# For backwords-compat with earlier hip 0.4 and earlier.
# For backwords-compat with urllib3 0.4 and earlier.
if self._body is not None:
return self._body

Expand Down Expand Up @@ -321,7 +321,7 @@ def _flush_decoder(self):
@contextmanager
def _error_catcher(self):
"""
Catch low-level python exceptions, instead re-raising hip
Catch low-level python exceptions, instead re-raising Hip
variants, so that low-level exceptions are not leaked in the
high-level api.
Expand Down
2 changes: 1 addition & 1 deletion src/hip/_backends/twisted_backend.py
Expand Up @@ -178,7 +178,7 @@ async def start_tls(self, server_hostname, ssl_context):
await self._protocol.start_tls(server_hostname, ssl_context)

def getpeercert(self, binary_form=False):
# Cribbed from hip .contrib.pyopenssl.WrappedSocket.getpeercert
# Cribbed from hip.contrib.pyopenssl.WrappedSocket.getpeercert
x509 = self._protocol.transport.getPeerCertificate()
if not x509:
return x509
Expand Down
2 changes: 1 addition & 1 deletion src/hip/backends.py
Expand Up @@ -2,7 +2,7 @@ class Backend:
"""
Specifies the desired backend and any arguments passed to its constructor.
Projects that use hip can subclass this interface to expose it to users.
Projects that use Hip can subclass this interface to expose it to users.
"""

def __init__(self, name, **kwargs):
Expand Down
12 changes: 6 additions & 6 deletions src/hip/base.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
"""
This module provides the base structure of the Request/Response objects that
hip passes around to manage its HTTP semantic layer.
Hip passes around to manage its HTTP semantic layer.
These objects are the lowest common denominator: that is, they define the
Request/Response functionality that is always supported by hip. This means
Request/Response functionality that is always supported by Hip. This means
they do not include any extra function required for asynchrony: that
functionality is handled elsewhere. Any part of hip is required to be able
functionality is handled elsewhere. Any part of Hip is required to be able
to work with one of these objects.
"""
from ._collections import HTTPHeaderDict
Expand All @@ -26,7 +26,7 @@ class Request(object):
and love: it has a method, a target (the path & query portions of a URI),
some headers, and optionally a body.
All of hip manipulates these Request objects, passing them around and
All of Hip manipulates these Request objects, passing them around and
changing them as necessary. The low-level layers know how to send these
objects.
"""
Expand Down Expand Up @@ -79,9 +79,9 @@ def add_host(self, host, port, scheme):

class Response(object):
"""
The abstract low-level Response object that hip works on. This is not
The abstract low-level Response object that Hip works on. This is not
the high-level helpful Response object that is exposed at the higher layers
of hip: it's just a simple object that just exposes the lowest-level
of Hip: it's just a simple object that just exposes the lowest-level
HTTP semantics to allow processing by the higher levels.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/hip/contrib/_securetransport/bindings.py
Expand Up @@ -6,7 +6,7 @@
This code is a bastardised version of the code found in Will Bond's oscrypto
library. An enormous debt is owed to him for blazing this trail for us. For
that reason, this code should be considered to be covered both by hip's
that reason, this code should be considered to be covered both by Hip's
license and by oscrypto's:
Copyright (c) 2015-2016 Will Bond <will@wbond.net>
Expand Down
6 changes: 3 additions & 3 deletions src/hip/contrib/pyopenssl.py
Expand Up @@ -78,7 +78,7 @@ class UnsupportedExtension(Exception):
# SNI always works.
HAS_SNI = True

# Map from hip to PyOpenSSL compatible parameter-values.
# Map from Hip to PyOpenSSL compatible parameter-values.
_openssl_versions = {
util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
Expand Down Expand Up @@ -115,7 +115,7 @@ class UnsupportedExtension(Exception):


def inject_into_hip():
"Monkey-patch hip with PyOpenSSL-backed SSL-support."
"Monkey-patch Hip with PyOpenSSL-backed SSL-support."

_validate_dependencies_met()

Expand Down Expand Up @@ -244,7 +244,7 @@ def get_subj_alt_name(peer_cert):
# no SAN field is present.
log.warning(
"A problem was encountered with the certificate that prevented "
"hip from finding the SubjectAlternativeName field. This can "
"Hip from finding the SubjectAlternativeName field. This can "
"affect certificate validation. The error was %s",
e,
)
Expand Down
12 changes: 6 additions & 6 deletions src/hip/contrib/securetransport.py
@@ -1,7 +1,7 @@
"""
SecureTranport support for hip via ctypes.
SecureTranport support for Hip via ctypes.
This makes platform-native TLS available to hip users on macOS without the
This makes platform-native TLS available to Hip users on macOS without the
use of a compiler. This is an important feature because the Python Package
Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL
that ships with macOS is not capable of doing TLSv1.2. The only way to resolve
Expand All @@ -26,7 +26,7 @@
This code is a bastardised version of the code found in Will Bond's oscrypto
library. An enormous debt is owed to him for blazing this trail for us. For
that reason, this code should be considered to be covered both by hip's
that reason, this code should be considered to be covered both by Hip's
license and by oscrypto's:
Copyright (c) 2015-2016 Will Bond <will@wbond.net>
Expand Down Expand Up @@ -179,7 +179,7 @@

def inject_into_hip():
"""
Monkey-patch hip with SecureTransport-backed SSL-support.
Monkey-patch Hip with SecureTransport-backed SSL-support.
"""
util.SSLContext = SecureTransportContext
util.ssl_.SSLContext = SecureTransportContext
Expand Down Expand Up @@ -649,7 +649,7 @@ def getpeercert(self, binary_form=False):
# This is gross. Really gross. It's going to be a few hundred LoC extra
# just to repeat something that SecureTransport can *already do*. So my
# operating assumption at this time is that what we want to do is
# instead to just flag to hip that it shouldn't do its own hostname
# instead to just flag to Hip that it shouldn't do its own hostname
# validation when using SecureTransport.
if not binary_form:
raise ValueError("SecureTransport only supports dumping binary certs")
Expand Down Expand Up @@ -800,7 +800,7 @@ def set_default_verify_paths(self):
#
# This means that, if we had previously had load_verify_locations
# called, this does not undo that. We need to do that because it turns
# out that the rest of the hip code will attempt to load the
# out that the rest of the Hip code will attempt to load the
# default verify paths if it hasn't been told about any paths, even if
# the context itself was sometime earlier. We resolve that by just
# ignoring it.
Expand Down
8 changes: 4 additions & 4 deletions src/hip/contrib/socks.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
"""
This module contains provisional support for SOCKS proxies from within
hip. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
Hip. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
SOCKS5. To enable its functionality, either install PySocks or install this
module with the ``socks`` extra.
The SOCKS implementation supports the full range of hip features. It also
The SOCKS implementation supports the full range of Hip features. It also
supports the following SOCKS features:
- SOCKS4A (``proxy_url='socks4a://...``)
Expand Down Expand Up @@ -44,7 +44,7 @@

warnings.warn(
(
"SOCKS support in hip requires the installation of optional "
"SOCKS support in Hip requires the installation of optional "
"dependencies: specifically, PySocks. For more information, see "
"https://hip.readthedocs.io/en/latest/contrib.html#socks-proxies"
),
Expand Down Expand Up @@ -132,7 +132,7 @@ class SOCKSHTTPSConnectionPool(HTTPSConnectionPool):

class SOCKSProxyManager(PoolManager):
"""
A version of the hip ProxyManager that routes connections via the
A version of the Hip ProxyManager that routes connections via the
defined SOCKS proxy.
"""

Expand Down
4 changes: 2 additions & 2 deletions src/hip/exceptions.py
Expand Up @@ -218,7 +218,7 @@ def __init__(self, defects, unparsed_data):


class UnrewindableBodyError(HTTPError):
"hip encountered an error when trying to rewind a body"
"Hip encountered an error when trying to rewind a body"
pass


Expand All @@ -234,7 +234,7 @@ def __init__(self, message, response):

class InvalidBodyError(HTTPError):
"""
An attempt was made to send a request with a body object that hip does
An attempt was made to send a request with a body object that Hip does
not support.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/hip/util/retry.py
Expand Up @@ -114,7 +114,7 @@ class Retry(object):
:param float backoff_factor:
A backoff factor to apply between attempts after the second try
(most errors are resolved immediately by a second try without a
delay). hip will sleep for::
delay). Hip will sleep for::
{backoff factor} * (2 ** ({number of total retries} - 1))
Expand Down
4 changes: 2 additions & 2 deletions src/hip/util/ssl_.py
Expand Up @@ -151,7 +151,7 @@ def set_ciphers(self, cipher_suite):
def wrap_socket(self, socket, server_hostname=None, server_side=False):
warnings.warn(
"A true SSLContext object is not available. This prevents "
"hip from configuring SSL appropriately and may cause "
"Hip from configuring SSL appropriately and may cause "
"certain SSL connections to fail. You can upgrade to a newer "
"version of Python to solve this. For more information, see "
"https://hip.readthedocs.io/en/latest/advanced-usage.html"
Expand Down Expand Up @@ -387,7 +387,7 @@ def ssl_wrap_socket(
context = ssl_context
if context is None:
# Note: This branch of code and all the variables in it are no longer
# used by hip itself. We should consider deprecating and removing
# used by Hip itself. We should consider deprecating and removing
# this code.
context = create_ssl_context(ssl_version, cert_reqs, ciphers=ciphers)

Expand Down
5 changes: 2 additions & 3 deletions src/hip/util/timeout.py
Expand Up @@ -7,8 +7,7 @@

from ..exceptions import TimeoutStateError

# A sentinel value to indicate that no timeout was specified by the user in
# hip
# A sentinel value to indicate that no timeout was specified by the user in Hip
_Default = object()


Expand Down Expand Up @@ -67,7 +66,7 @@ class Timeout(object):
.. note::
Many factors can affect the total amount of time for hip to return
Many factors can affect the total amount of time for Hip to return
an HTTP response.
For example, Python's DNS resolver does not obey the timeout specified
Expand Down
2 changes: 1 addition & 1 deletion src/hip/util/url.py
Expand Up @@ -9,7 +9,7 @@
url_attrs = ["scheme", "auth", "host", "port", "path", "query", "fragment"]

# We only want to normalize urls with an HTTP(S) scheme.
# hip infers URLs without a scheme (None) to be http.
# Hip infers URLs without a scheme (None) to be http.
NORMALIZABLE_SCHEMES = ("http", "https", None)

# Almost all of these patterns were derived from the
Expand Down
4 changes: 2 additions & 2 deletions test/test_connectionpool.py
Expand Up @@ -126,7 +126,7 @@ def test_not_same_host(self, a, b):
],
)
def test_same_host_no_port_http(self, a, b):
# This test was introduced in urllib3/urllib3#801 to deal with the fact that hip
# This test was introduced in urllib3/urllib3#801 to deal with the fact that Hip
# never initializes ConnectionPool objects with port=None.
with HTTPConnectionPool(a) as c:
assert c.is_same_host(b)
Expand All @@ -143,7 +143,7 @@ def test_same_host_no_port_http(self, a, b):
],
)
def test_same_host_no_port_https(self, a, b):
# This test was introduced in urllib3/urllib3#801 to deal with the fact that hip
# This test was introduced in urllib3/urllib3#801 to deal with the fact that Hip
# never initializes ConnectionPool objects with port=None.
with HTTPSConnectionPool(a) as c:
assert c.is_same_host(b)
Expand Down
2 changes: 1 addition & 1 deletion test/test_response.py
Expand Up @@ -561,7 +561,7 @@ def test_empty_stream(self):
next(stream)

def test_mock_httpresponse_stream(self):
# Mock out a HTTP Request that does enough to make it through hip's
# Mock out a HTTP Request that does enough to make it through Hip's
# read() and close() calls, and also exhausts and underlying file
# object.
class MockHTTPRequest(object):
Expand Down
2 changes: 1 addition & 1 deletion test/with_dummyserver/test_poolmanager.py
Expand Up @@ -424,7 +424,7 @@ def test_retries_wrong_whitelist(self):
assert resp.status == 418

def test_default_method_whitelist_retried(self):
""" hip should retry methods in the default method whitelist """
"""Hip should retry methods in the default method whitelist"""
retry = Retry(total=1, status_forcelist=[418])

with PoolManager() as http:
Expand Down

0 comments on commit 47395cb

Please sign in to comment.