Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merging new release version: 1.15
  • Loading branch information
shazow committed Apr 6, 2016
2 parents 27df29b + 30dc7a5 commit 32cfb59
Show file tree
Hide file tree
Showing 38 changed files with 864 additions and 156 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,5 +1,6 @@
language: python
script: tox
script:
- ./_travis/travis-run.sh
before_install:
- openssl version
cache:
Expand All @@ -17,7 +18,6 @@ env:
- TOXENV=flake8-py3
- TOXENV=py26
- TOXENV=py27
- TOXENV=py32
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
Expand Down
24 changes: 24 additions & 0 deletions CHANGES.rst
@@ -1,6 +1,30 @@
Changes
=======

1.15 (2016-04-06)
+++++++++++++++++

* Added Retry(raise_on_status=False). (Issue #720)

* Always use setuptools, no more distutils fallback. (Issue #785)

* Dropped support for Python 3.2. (Issue #786)

* Chunked transfer encoding when requesting with ``chunked=True``.
(Issue #790)

* Fixed regression with IPv6 port parsing. (Issue #801)

* Append SNIMissingWarning messages to allow users to specify it in
the PYTHONWARNINGS environment variable. (Issue #816)

* Handle unicode headers in Py2. (Issue #818)

* Log certificate when there is a hostname mismatch. (Issue #820)

* Preserve order of request/response headers. (Issue #821)


1.14 (2015-12-29)
+++++++++++++++++

Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -187,5 +187,15 @@ In chronological order:
* Ville Skyttä <ville.skytta@iki.fi>
* Logging efficiency improvements, spelling fixes, Travis config.

* Shige Takeda <smtakeda@gmail.com>
* Started Recipes documentation and added a recipe about handling concatenated gzip data in HTTP response

* Jesse Shapiro <jesse@jesseshapiro.net>
* Working on encoding unicode header parameter names
* Making setup.py resilient to ASCII locales

* David Foster <http://dafoster.net/>
* Ensure order of request and response headers are preserved.

* [Your name or handle] <[email or website]>
* [Brief summary of your changes]
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,6 +1,6 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright 2008-2014 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
Copyright 2008-2016 Andrey Petrov and contributors (see CONTRIBUTORS.txt)

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
Expand Down
16 changes: 16 additions & 0 deletions README.rst
Expand Up @@ -18,6 +18,7 @@ Highlights
- File posting (``encode_multipart_formdata``).
- Built-in redirection and retries (optional).
- Supports gzip and deflate decoding.
- Proxy over HTTP or SOCKS.
- Thread-safe and sanity-safe.
- Works with AppEngine, gevent, and eventlib.
- Tested on Python 2.6+, Python 3.2+, and PyPy, with 100% unit test coverage.
Expand Down Expand Up @@ -126,6 +127,21 @@ Our test suite `runs continuously on Travis CI
Contributing
============

Thank you for giving back to urllib3. Please meet our jolly team
of code-sherpas:

Maintainers
-----------

- `@lukasa <https://github.com/lukasa>`_ (Cory Benfield)
- `@sigmavirus24 <https://github.com/sigmavirus24>`_ (Ian Cordasco)
- `@shazow <https://github.com/shazow>`_ (Andrey Petrov)

👋

Getting Started
---------------

#. `Check for open issues <https://github.com/shazow/urllib3/issues>`_ or open
a fresh issue to start a discussion around a feature idea or a bug. There is
a *Contributor Friendly* tag for issues that should be ideal for people who
Expand Down
12 changes: 12 additions & 0 deletions _travis/travis-install.sh
Expand Up @@ -4,6 +4,18 @@ set -ev

pip install tox==2.1.1

# Workaround Travis' old PyPy release. If Travis updates, we can remove this
# code.
if [[ "${TOXENV}" == pypy* ]]; then
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
pyenv install pypy-4.0.1
pyenv global pypy-4.0.1
pyenv rehash
fi

if [[ "${TOXENV}" == "gae" && ! -d ${GAE_PYTHONPATH} ]]; then
python _travis/fetch_gae_sdk.py `dirname ${GAE_PYTHONPATH}`
fi
11 changes: 11 additions & 0 deletions _travis/travis-run.sh
@@ -0,0 +1,11 @@
#!/bin/bash

set -ev

if [[ "${TOXENV}" == "pypy" ]]; then
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi

tox
1 change: 1 addition & 0 deletions dev-requirements.txt
Expand Up @@ -6,3 +6,4 @@ tox==2.1.1
twine==1.5.0
wheel==0.24.0
tornado==4.2.1
PySocks==1.5.6
10 changes: 3 additions & 7 deletions docs/contrib.rst
Expand Up @@ -52,10 +52,12 @@ There are `limitations <https://cloud.google.com/appengine/docs/python/urlfetch/
3. If you are using `Managed VMs <https://cloud.google.com/appengine/docs/managed-vms/>`_, you can use the standard :class:`PoolManager` without any configuration or special environment variables.


.. _socks:

SOCKS Proxies
-------------

.. versionadded:: 1.14.0
.. versionadded:: 1.14

The :mod:`urllib3.contrib.socks` module enables urllib3 to work with proxies
that use either the SOCKS4 or SOCKS5 protocols. These proxies are common in
Expand All @@ -65,12 +67,6 @@ but don't want unrestricted traffic flows.
To use it, either install ``PySocks`` or install urllib3 with the ``socks``
extra, like so:

.. code-block:: bash
$ pip install urllib3[socks]
If you have already got urllib3 1.14.0 or later installed, run:

.. code-block:: bash
$ pip install -U urllib3[socks]
Expand Down
54 changes: 31 additions & 23 deletions docs/index.rst
Expand Up @@ -12,6 +12,7 @@ urllib3 Documentation
exceptions
collections
contrib
recipes


Highlights
Expand All @@ -22,7 +23,7 @@ Highlights
:class:`~urllib3.connectionpool.HTTPConnectionPool` and
:class:`~urllib3.connectionpool.HTTPSConnectionPool`

- File posting. See:
- File posting with multipart encoding. See:
:func:`~urllib3.filepost.encode_multipart_formdata`

- Built-in redirection and retries (optional).
Expand All @@ -33,12 +34,14 @@ Highlights

- Thread-safe and sanity-safe.

- Proxy over :ref:`HTTP or SOCKS <proxymanager>`.

- Tested on Python 2.6+ and Python 3.2+, 100% unit test coverage.

- Works with AppEngine, gevent, eventlib, and the standard library :mod:`io` module.

- Small and easy to understand codebase perfect for extending and building upon.
For a more comprehensive solution, have a look at
For a simplified abstraction, have a look at
`Requests <http://python-requests.org/>`_ which is also powered by urllib3.


Expand Down Expand Up @@ -153,13 +156,18 @@ A :class:`~urllib3.poolmanagers.PoolManager` is a proxy for a collection of
similar, so that instances of either can be passed around interchangeably.


.. _proxymanager:

ProxyManager
------------

HTTP Proxy
~~~~~~~~~~

The :class:`~urllib3.poolmanagers.ProxyManager` is an HTTP proxy-aware
subclass of :class:`~urllib3.poolmanagers.PoolManager`. It produces a single
:class:`~urllib3.connectionpool.HTTPConnectionPool` instance for all HTTP
connections and individual per-server:port
connections and individual per-``server:port``
:class:`~urllib3.connectionpool.HTTPSConnectionPool` instances for tunnelled
HTTPS connections:

Expand All @@ -176,6 +184,12 @@ HTTPS connections:
3


SOCKS Proxy
~~~~~~~~~~~

The :ref:`contrib module <socks>` includes support for a :class:`SOCKSProxyManager <urllib3.contrib.socks.SOCKSProxyManager>`.


ConnectionPool
--------------

Expand Down Expand Up @@ -353,36 +367,30 @@ Sponsorship
Please consider sponsoring urllib3 development, especially if your company
benefits from this library.

* **Project Grant**: A grant for contiguous full-time development has the
biggest impact for progress. Periods of 3 to 10 days allow a contributor to
tackle substantial complex issues which are otherwise left to linger until
somebody can't afford to not fix them.

Contact `@shazow <https://github.com/shazow>`_ to arrange a grant for a core
contributor.
We welcome your patronage on `Bountysource <https://www.bountysource.com/teams/urllib3>`_:

* **One-off**: Development will continue regardless of funding, but donations help move
things further along quicker as the maintainer can allocate more time off to
work on urllib3 specifically.
* `Contribute a recurring amount to the team <https://salt.bountysource.com/checkout/amount?team=urllib3>`_
* `Place a bounty on a specific feature <https://www.bountysource.com/teams/urllib3>`_

.. raw:: html
Your contribution will go towards adding new features to urllib3 and making
sure all functionality continues to meet our high quality standards.

<a href="https://donorbox.org/personal-sponsor-urllib3" style="background-color:#1275ff;color:#fff;text-decoration:none;font-family:Verdana,sans-serif;display:inline-block;font-size:14px;padding:7px 16px;border-radius:5px;margin-right:2em;vertical-align:top;border:1px solid rgba(160,160,160,0.5);background-image:linear-gradient(#7dc5ee,#008cdd 85%,#30a2e4);box-shadow:inset 0 1px 0 rgba(255,255,255,0.25);">Sponsor with Credit Card</a>

<a class="coinbase-button" data-code="137087702cf2e77ce400d53867b164e6" href="https://coinbase.com/checkouts/137087702cf2e77ce400d53867b164e6">Sponsor with Bitcoin</a>
<script src="https://www.coinbase.com/assets/button.js" type="text/javascript"></script>
Project Grant
-------------

* **Recurring**: You're welcome to `support the maintainer on Gittip
<https://www.gittip.com/shazow/>`_.
A grant for contiguous full-time development has the biggest impact for
progress. Periods of 3 to 10 days allow a contributor to tackle substantial
complex issues which are otherwise left to linger until somebody can't afford
to not fix them.


Recent Sponsors
---------------
Contact `@shazow <https://github.com/shazow>`_ to arrange a grant for a core
contributor.

Huge thanks to all the companies and individuals who financially contributed to
the development of urllib3. Please send a PR if you've donated and would like
to be listed.

* `Stripe <https://stripe.com/>`_ (June 23, 2014)

.. * [Company] ([optional tagline]), [optional description of grant] ([date])
.. * [Company] ([date])
41 changes: 41 additions & 0 deletions docs/recipes.rst
@@ -0,0 +1,41 @@
Recipes
=======

This page includes a collection of recipes in the urlib3 cookbook.

Decode HTTP Response Data in Concatenated Gzip Format
-----------------------------------------------------

By default, urllib3 checks ``Content-Encoding`` header in HTTP response and decodes the data in ``gzip`` or ``deflate`` transparently. If ``Content-Encoding`` is not either of them, however, you will have to decode data in your application.

This recipe shows how to decode data in the concatenated gzip format where multiple gzipped data chunks are concatenated in HTTP response.

.. doctest ::
import zlib
import urllib3
CHUNK_SIZE = 1024
def decode_gzip_raw_content(raw_data_fd):
obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
output = []
d = raw_data_fd.read(CHUNK_SIZE)
while d:
output.append(obj.decompress(d))
while obj.unused_data != b'':
unused_data = obj.unused_data
obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
output.append(obj.decompress(unused_data))
d = raw_data_fd.read(CHUNK_SIZE)
return b''.join(output)
def test_urllib3_concatenated_gzip_in_http_response():
# example for urllib3
http = urllib3.PoolManager()
r = http.request('GET', 'http://example.com/abc.txt',
decode_content=False, preload_content=False)
content = decode_gzip_raw_content(r).decode('utf-8')
``obj.unused_data`` includes the left over data in the previous ``obj.decompress`` method call. A new ``zlib.decompressobj`` is used to start decoding the next gzipped data chunk until no further data is given.
2 changes: 1 addition & 1 deletion docs/security.rst
Expand Up @@ -17,7 +17,7 @@ Python with SSL enabled
-----------------------

First we need to make sure your Python installation has SSL enabled. Easiest
way to check is to simply open a Python shell and type `import ssl`::
way to check is to simply open a Python shell and type ``import ssl``::

>>> import ssl
Traceback (most recent call last):
Expand Down
31 changes: 15 additions & 16 deletions dummyserver/certs/server.crt
@@ -1,22 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDqDCCAxGgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UEBhMCRkkx
DjAMBgNVBAgTBWR1bW15MQ4wDAYDVQQHEwVkdW1teTEOMAwGA1UEChMFZHVtbXkx
DjAMBgNVBAsTBWR1bW15MREwDwYDVQQDEwhTbmFrZU9pbDEfMB0GCSqGSIb3DQEJ
MIIDczCCAtygAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UEBhMCRkkx
DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQHDAVkdW1teTEOMAwGA1UECgwFZHVtbXkx
DjAMBgNVBAsMBWR1bW15MREwDwYDVQQDDAhTbmFrZU9pbDEfMB0GCSqGSIb3DQEJ
ARYQZHVtbXlAdGVzdC5sb2NhbDAeFw0xMTEyMjIwNzU4NDBaFw0yMTEyMTgwNzU4
NDBaMGExCzAJBgNVBAYTAkZJMQ4wDAYDVQQIEwVkdW1teTEOMAwGA1UEBxMFZHVt
bXkxDjAMBgNVBAoTBWR1bW15MQ4wDAYDVQQLEwVkdW1teTESMBAGA1UEAxMJbG9j
NDBaMGExCzAJBgNVBAYTAkZJMQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UEBwwFZHVt
bXkxDjAMBgNVBAoMBWR1bW15MQ4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3NyBLszCi2hgYekgYQwgYExCzAJBgNVBAYTAkZJMQ4wDAYDVQQIDAVk
dW1teTEOMAwGA1UEBwwFZHVtbXkxDjAMBgNVBAoMBWR1bW15MQ4wDAYDVQQLDAVk
dW1teTERMA8GA1UEAwwIU25ha2VPaWwxHzAdBgkqhkiG9w0BCQEWEGR1bW15QHRl
c3QubG9jYWyCCQCz67HKL+G/4zAJBgNVHRIEAjAAMCQGA1UdEQQdMBuBDnJvb3RA
bG9jYWxob3N0gglsb2NhbGhvc3QwDQYJKoZIhvcNAQEFBQADgYEAgcW6X1ZUyufm
TFEqEAdpKXdL0rxDwcsM/qqqsXbkz17otH6ujPhBEagzdKtgeNKfy0aXz6rWZugk
lF0IqyC4mcI+vvfgGR5Iy4KdXMrIX98MbrvGJBfbdKhGW2b84wDV42DIDiD2ZGGe
6YZQQIo9LxjuOTf9jsvf+PIkbI4H0To=
-----END CERTIFICATE-----
5 changes: 5 additions & 0 deletions dummyserver/handlers.py
Expand Up @@ -246,6 +246,11 @@ def nbytes(self, request):
data,
headers=[('Content-Type', 'application/octet-stream')])

def status(self, request):
status = request.params.get("status", "200 OK")

return Response(status=status)

def shutdown(self, request):
sys.exit()

Expand Down

0 comments on commit 32cfb59

Please sign in to comment.