diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 00000000..5133965f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +Summary. + +## Expected Result + +What you expected. + +## Actual Result + +What happened instead. + +## Reproduction Steps + +```python +import requests + +``` + +## System Information + + $ python -m requests.help + +``` + +``` + +This command is only available on Requests v2.16.4 and greater. Otherwise, +please provide some basic information about your system (Python version, +operating system, &c). diff --git a/.github/ISSUE_TEMPLATE/Custom.md b/.github/ISSUE_TEMPLATE/Custom.md new file mode 100644 index 00000000..22ed2e17 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Custom.md @@ -0,0 +1,7 @@ +--- +name: Request for Help +about: Guidance on using Requests. + +--- + +Please refer to our [StackOverflow tag](https://stackoverflow.com/questions/tagged/python-requests) for guidance. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 00000000..dcf6a445 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,7 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +Requests is not accepting feature requests at this time. diff --git a/.gitignore b/.gitignore index 19ebfd79..cd0c32e9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ t.py t2.py dist + +/.mypy_cache/ diff --git a/AUTHORS.rst b/AUTHORS.rst index 2b4494ba..907687d4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -1,13 +1,17 @@ Requests is written and maintained by Kenneth Reitz and various contributors: -Keepers of the Four Crystals -```````````````````````````` +Keepers of the Crystals +``````````````````````` - Kenneth Reitz `@kennethreitz `_, Keeper of the Master Crystal. +- Ian Cordasco `@sigmavirus24 `_. +- Nate Prewitt `@nateprewitt `_. + +Previous Keepers of Crystals +```````````````````````````` + - Cory Benfield `@lukasa `_ -- Ian Cordasco `@sigmavirus24 `_ -- Nate Prewitt `@nateprewitt `_ Patches and Suggestions diff --git a/LICENSE b/LICENSE index db78ea69..2e68b82e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2017 Kenneth Reitz +Copyright 2018 Kenneth Reitz Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Pipfile b/Pipfile index 716c0058..3e0fd729 100644 --- a/Pipfile +++ b/Pipfile @@ -1,24 +1,24 @@ [[source]] -url = "https://pypi.python.org/simple" +url = "https://pypi.org/simple/" verify_ssl = true +name = "pypi" [dev-packages] - pytest = ">=2.8.0" codecov = "*" -"pytest-httpbin" = "==0.0.7" -"pytest-mock" = "*" -"pytest-cov" = "*" -"pytest-xdist" = "*" +pytest-httpbin = ">=0.0.7" +pytest-mock = "*" +pytest-cov = "*" +pytest-xdist = "*" alabaster = "*" -"readme-renderer" = "*" +readme-renderer = "*" sphinx = "<=1.5.5" pysocks = "*" docutils = "*" "flake8" = "*" tox = "*" detox = "*" -httpbin = "==0.5.0" +httpbin = ">=0.7.0" [packages] -"e1839a8" = {path = ".", editable = true, extras=["socks"]} \ No newline at end of file +"e1839a8" = {path = ".", editable = true, extras = ["socks"]} diff --git a/README.rst b/README.rst index c7b033be..d65fd947 100644 --- a/README.rst +++ b/README.rst @@ -2,13 +2,13 @@ Requests: HTTP for Humans ========================= .. image:: https://img.shields.io/pypi/v/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://img.shields.io/pypi/l/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://img.shields.io/pypi/pyversions/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master :target: https://codecov.io/github/requests/requests diff --git a/appveyor.yml b/appveyor.yml index 1da1fa88..d3f3ca19 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,8 +41,9 @@ install: # Upgrade to the latest version of pip to avoid it displaying warnings # about it being out of date. - - "pip install --disable-pip-version-check --user --upgrade pip" + - "python -m pip install --upgrade pip wheel" - "C:\\MinGW\\bin\\mingw32-make" + - "pipenv install -e .[socks] --skip-lock" test_script: - "C:\\MinGW\\bin\\mingw32-make coverage" diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 3a8af312..54def686 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -1,3 +1,11 @@ +body > div.document > div.sphinxsidebar > div > form > table > tbody > tr:nth-child(2) > td > select { + width: 100%!important; +} + +#python27 > a { + color: white; +} + #carbonads { display: block; overflow: hidden; diff --git a/docs/_templates/hacks.html b/docs/_templates/hacks.html index 0d88a6ec..c3fe2d1e 100644 --- a/docs/_templates/hacks.html +++ b/docs/_templates/hacks.html @@ -1,7 +1,6 @@ @@ -20,14 +19,14 @@ } - + diff --git a/docs/_templates/sidebarintro.html b/docs/_templates/sidebarintro.html index 0b35068c..bdb1c024 100644 --- a/docs/_templates/sidebarintro.html +++ b/docs/_templates/sidebarintro.html @@ -13,10 +13,12 @@ Requests is an elegant and simple HTTP library for Python, built for human beings.

+

Sponsored by Linode and other wonderful organizations.

+ -

Stickers!

+

Requests Stickers!

Stay Informed

Receive updates on new releases and upcoming projects.

@@ -24,7 +26,6 @@ allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20">

-

Say Thanks!

Join Mailing List.

Other Projects

@@ -50,7 +51,7 @@

  • Requests @ GitHub
  • -
  • Requests @ PyPI
  • +
  • Requests @ PyPI
  • Issue Tracker
  • Release History
  • diff --git a/docs/_templates/sidebarlogo.html b/docs/_templates/sidebarlogo.html index 6453fa2b..1b7afbd8 100644 --- a/docs/_templates/sidebarlogo.html +++ b/docs/_templates/sidebarlogo.html @@ -8,23 +8,26 @@ allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px">

    +

    Requests is an elegant and simple HTTP library for Python, built for human beings. You are currently looking at the documentation of the development release.

    -

    Stickers!

    + +

    Sponsored by Linode and other wonderful organizations.

    +

    Stay Informed

    Receive updates on new releases and upcoming projects.

    +

    Requests Stickers!

    +

    Join Mailing List.


    -

    If you enjoy using this project, Say Thanks!

    -

    diff --git a/docs/community/sponsors.rst b/docs/community/sponsors.rst new file mode 100644 index 00000000..f1e11efd --- /dev/null +++ b/docs/community/sponsors.rst @@ -0,0 +1,96 @@ +Community Sponsors +================== + +**tl;dr**: Requests development is currently `funded by the Python community `_, and +some wonderful organizations that utilize the software in their businesses. + + +------------------- + + +Requests is one of the most heavily–utilized Python packages in the world. + +It is used by major corporations worldwide for all tasks, both small and large — from writing one–off scripts to orchestrating millions of dollars of critical infrastructure. + +It's even embedded within pip, that tool that you use to install packages and deploy with every day! + +After losing our primary open source maintainer (who was sponsored by a company to work on Requests, and other projects, full–time), we are seeking community financial contributions towards the development of Requests 3.0. + +Patron Sponsors +---------------- + + +`Linode — SSD Cloud Hosting & Linux Servers `_ +////////////////////////////////////////////////////////////////////// + +Whether you’re just getting started or deploying a complex system, launching a Linode cloud server has never been easier. They offer the fastest hardware and network in the industry with scalable environments, and their 24x7 customer support team is always standing by to help with any questions. + +✨🍰✨ +////// + +---------------------------------- + +This slot is reserved for ethical organizations willing to invest $10,000 or more in Requests per year. + +By becoming a patron–level sponsor, your organization will receive the following benefits: + +- Prominent placement on the Requests documentation sidebar (~11,000 uniques / day). +- Honorable mention here, with logo. +- Peace of mind knowing that the infrastructure you rely on is being actively maintained. + +Organizations that sign up will be listed in order — first come first serve! + +Major Sponsors +-------------- + +The following organizations have significantly contributed towards Requests' sustainability: + +`Slack — Bring your team together `_ +/////////////////////////////////////////////////////// + +Slack was extremely kind to be the first organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser `_, surpassing our entire fundraising goal immediately! They are helping the world become a better place through connectiveness, and reducing the amount of email we all have +to deal with on a daily basis. + +P.S. They're `hiring `_! + + +`Twilio — Voice, SMS, and Video for Humans `_ +///////////////////////////////////////////////////////////////////// + +Twilio was the second organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser `_, matching the donation of Slack! They are helping the world become a better place through interconnectivity, +providing easy–to–use APIs, and empowering developers world-over to help humans communicate in meaningful and effictive ways. + + +`Azure Cloud Developer Advocates `_ +///////////////////////////////////////////////////////////////////////////////////// + +Azure was the third organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser `_, matching the donation of Twilio! Awesome group of generous folks :) + + +`Niteo — Web Systems Development `_ +///////////////////////////////////////////////////////////// + +Niteo was the fourth company to generously donate towards the `2018 Requests 3.0 fundraiser `_. Niteo is a company employing tech enthusiasts from all over the world +who love to build great stuff. + + +`Heroku `_ +///////////////////////////////////// + +Heroku has allowed Kenneth Reitz to work on some open source projects during work hours, +including Requests (but mostly Pipenv), from time–to–time, so they are listed +here as an honorable mention. + +---------------- + +If your organization is interested in becoming either a sponsor or a patron, please `send us an email `_. + + +Individual Sponsors +------------------- + +Countless individuals, too many to list here, have individually contributed towards the sustainability of the Requests +project over the years. Some, financially, others, with code. Contributions (from humans) of all kinds are greatly +appreciated. + +✨🍰✨ \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 7934a298..918e2dcf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,13 +9,13 @@ Requests: HTTP for Humans Release v\ |version|. (:ref:`Installation `) .. image:: https://img.shields.io/pypi/l/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://img.shields.io/pypi/wheel/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://img.shields.io/pypi/pyversions/requests.svg - :target: https://pypi.python.org/pypi/requests + :target: https://pypi.org/project/requests/ .. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master :target: https://codecov.io/github/requests/requests @@ -64,7 +64,7 @@ PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington Post, SoundCloud, Kippt, Sony, and Federal U.S. Institutions that prefer to be unnamed claim to use Requests internally. -**Armin Ronacher**— +**Armin Ronacher**, creator of Flask— *Requests is the perfect example how beautiful an API can be with the right level of abstraction.* @@ -74,14 +74,18 @@ Institutions that prefer to be unnamed claim to use Requests internally. **Daniel Greenfeld**— *Nuked a 1200 LOC spaghetti code library with 10 lines of code thanks to - Kenneth Reitz's request library. Today has been AWESOME.* + Kenneth Reitz's Requests library. Today has been AWESOME.* **Kenny Meyers**— *Python HTTP: When in doubt, or when not in doubt, use Requests. Beautiful, simple, Pythonic.* Requests is one of the most downloaded Python packages of all time, pulling in -over 13,000,000 downloads every month. All the cool kids are doing it! +over 400,000 downloads **each day**. Join the party! + +If your organization uses Requests internally, consider `supporting the development of 3.0 `_. Your +generosity will be greatly appreciated, and help drive the project forward +into the future. Beloved Features ---------------- @@ -133,6 +137,7 @@ Requests ecosystem and community. .. toctree:: :maxdepth: 2 + community/sponsors community/recommended community/faq community/out-there diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index e5f7f297..15f750d3 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -287,7 +287,7 @@ For the sake of security we recommend upgrading certifi frequently! .. _HTTP persistent connection: https://en.wikipedia.org/wiki/HTTP_persistent_connection .. _connection pooling: https://urllib3.readthedocs.io/en/latest/reference/index.html#module-urllib3.connectionpool -.. _certifi: http://certifi.io/ +.. _certifi: https://certifiio.readthedocs.io/ .. _Mozilla trust store: https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt .. _body-content-workflow: @@ -449,7 +449,7 @@ If an error occurs while executing your callback, a warning is given. If the callback function returns a value, it is assumed that it is to replace the data that was passed in. If the function doesn't return -anything, nothing else is effected. +anything, nothing else is affected. :: @@ -656,7 +656,7 @@ When you receive a response, Requests makes a guess at the encoding to use for decoding the response when you access the :attr:`Response.text ` attribute. Requests will first check for an encoding in the HTTP header, and if none is present, will use `chardet -`_ to attempt to guess the encoding. +`_ to attempt to guess the encoding. The only time Requests will not do this is if no explicit charset is present in the HTTP headers **and** the ``Content-Type`` diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index b0ff231b..032e70f8 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -283,6 +283,8 @@ the ``json`` parameter (added in version 2.4.2) and it will be encoded automatic Note, the ``json`` parameter is ignored if either ``data`` or ``files`` is passed. +Using the ``json`` parameter in the request will change the ``Content-Type`` in the header to ``application/json``. + POST a Multipart-Encoded File ----------------------------- diff --git a/requests/api.py b/requests/api.py index bc2115c1..a2cc84d7 100644 --- a/requests/api.py +++ b/requests/api.py @@ -20,7 +20,7 @@ def request(method, url, **kwargs): :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary or list of tuples ``[(key, value)]`` (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`. - :param json: (optional) json data to send in the body of the :class:`Request`. + :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload. diff --git a/requests/utils.py b/requests/utils.py index 3f50d485..07f8c7f7 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -696,6 +696,8 @@ def should_bypass_proxies(url, no_proxy): :rtype: bool """ + # Prioritize lowercase environment variables over uppercase + # to keep a consistent behaviour with other http projects (curl, wget). get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL