Raibek/requests-github-issues huggingface dataset:
ChunkedEncodingError: Connection broken: error 54 ECONNREST

Summary.
When using requests.request('Get', 'https://hazards.fema.gov/gis/nfhl/services/public/NFHLWMS/MapServer/WMSServer?REQUEST=GetCapabilities&service=WMS&version=1.1.0'), the described error was thrown out.

## Expected Result
The true value should be a XML document, which could be preview using the Chrome browser to open the link in the request.

## Actual Result

What happened instead. The described error was thrown.

## Reproduction Steps

```python
import requests
requests.request('Get', 'https://hazards.fema.gov/gis/nfhl/services/public/NFHLWMS/MapServer/WMSServer?REQUEST=GetCapabilities&service=WMS&version=1.1.0')
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  }, 
  "cryptography": {
    "version": "2.1.3"
  }, 
  "idna": {
    "version": "2.6"
  }, 
  "implementation": {
    "name": "CPython", 
    "version": "2.7.14"
  }, 
  "platform": {
    "release": "15.6.0", 
    "system": "Darwin"
  }, 
  "pyOpenSSL": {
    "openssl_version": "1010007f", 
    "version": "17.3.0"
  }, 
  "requests": {
    "version": "2.18.4"
  }, 
  "system_ssl": {
    "version": "100020ef"
  }, 
  "urllib3": {
    "version": "1.22"
  }, 
  "using_pyopenssl": true
}
```

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).

Hi there! Thanks for opening this issue. Unfortunately, it seems this is a request for help instead of a report of a defect in the project. Please use [StackOverflow](https://stackoverflow.com) for general usage questions instead and only report defects here.

Further, `ECONNRESET` means that the server is resetting the connection. The fact that it's a chunked encoding error means that the server is resetting your connection while giving you chunked data. It seems this is a problem with the server

Also, using the exact code you gave me, I do not get an exception but instead a 200 response.
Trying to install requests

I tried to install requests with

cd /tmp && curl -OL https://github.com/kennethreitz/requests/zipball/master && unzip master && cd requests* && sudo python setup.py install

and i got this :

curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

I also tried :

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py #install pip packet manager for python
sudo pip install request

and I got :

python: can't open file 'get-pip.py': [Errno 2] No such file or directory


Thanks for your help !


Hi there! Thanks for opening this issue. Unfortunately, it seems this is a request for help instead of a report of a defect in the project. Please use [StackOverflow](https://stackoverflow.com) for general usage questions instead and only report defects here.

To note, all of the errors you're getting are completely unrelated to Requests.

> curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

Is specifically from `curl`. It seems that `curl` isn't downloading the pip bootstrap either. Your system is the source of all your problems here.
getting an Attribute Error while testing api using python

hey i am facing the same isuues but not able to get where i am facing attribute errors:

[self.token= 'ywlGaT0X44WGEps98WDN8xyFMmJgfGTehKxT5heiq_A7yqa_xwM9z6s2ouB1R7LprEYaTtXoILzx713kYhvoOxQrPLsRuvEAhnHfpc0sRonNXRYJgD91P8c2_mJJJ58MYs2TiMCEXlByG2ODRrb9e5OA35l74HXAegMabFJE7GnLX_4ZCxD2EygFP8LKqamdfao66QXAmXW60nwWYOF7g3bPdQNH3eK2siY9yODd_pFJ2IpLxBiadEFvAWZj5Y'

self.headers = {'content-type': 'application/json',
'Authorization': 'token {}'.format(self.token)}

](url)getting an error like +1
def test_api_get(self):
# A get request (json example):

      response = requests.get(self.myurl, headers=self.header)

E AttributeError: 'CL_API' object has no attribute 'header'

Please give me some inputs on it



Hi @makwanaparth94, this is an issue in your code and your use of `self`. Whatever class you’re calling this with does not have a headers attribute.

For future reference, this ticket tracker is reserved for reporting defects in Requests. Please direct any inquiries for help to [StackOverflow](https://stackoverflow.com) with the Python-Requests tag. Thanks!
I am unable to run tests on threedotoh branch.

I am unable to run tests on threedotoh branch.

## Expected Result

Al tests should pass.

## Actual Result
```
Traceback (most recent call last):
  File "/home/rkulshreshtha/.local/share/virtualenvs/requests-mRwENnZg/lib/python3.6/site-packages/_pytest/config.py", line 329, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/home/rkulshreshtha/Desktop/foss/requests/tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/rkulshreshtha/.local/share/virtualenvs/requests-mRwENnZg/lib/python3.6/site-packages/_pytest/config.py", line 360, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/home/rkulshreshtha/Desktop/foss/requests/tests/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/rkulshreshtha/.local/share/virtualenvs/requests-mRwENnZg/lib/python3.6/site-packages/_pytest/config.py", line 366, in _importconftest
    mod = conftestpath.pyimport()
  File "/home/rkulshreshtha/.local/share/virtualenvs/requests-mRwENnZg/lib/python3.6/site-packages/py/_path/local.py", line 668, in pyimport
    __import__(modname)
  File "/home/rkulshreshtha/.local/share/virtualenvs/requests-mRwENnZg/lib/python3.6/site-packages/_pytest/assertion/rewrite.py", line 213, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/rkulshreshtha/Desktop/foss/requests/tests/conftest.py", line 4, in <module>
    from requests.compat import urljoin
ImportError: cannot import name 'urljoin'
ERROR: could not load /home/rkulshreshtha/Desktop/foss/requests/tests/conftest.py
```
## Reproduction Steps

```bash
$ git checkout threedotoh
$ pipenv --three
$ pipenv shell
$ pipenv install --dev
$ py.test
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.4"
  },
  "platform": {
    "release": "4.15.4-300.fc27.x86_64",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "3.0.0"
  },
  "system_ssl": {
    "version": "1010007f"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}

```

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).

it is being worked on :)

Check out the 3.0 branch, tests are passing there. 

thanks, @kennethreitz  so is 3.0 branch will be used for further development?

And I would like to help in type annotation the library how I should proceed?

@RatanShreshtha send pull requests to that branch! 

✨🍰✨

That is the current working plan.
Question about requests and cacert.pem

Since version 2.12.3, there have been a bunch of awesome changes done to requests till v 2.18.4.
But, 1 thing that has changed considerably is that the `cacert.pem` that used to come packaged with 2.12.3 is not available now. Hence, the alternate option is to use [`certifi.where()`](https://pypi.python.org/pypi/certifi) to find the `cacert.pem`.

But, a lot of libraries were written based on 2.12.3 and not all of them have caught up to the changes made till 2.184, especially finding the right `cacert.pem` leading to this error -
```python
 IOError: Could not find a suitable TLS CA certificate bundle, invalid path: /<path>/virtualenv/lib/python2.7/site-packages/requests/cacert.pem
```

One way to get around this problem is to fix those libraries. Few (but not all) examples -
1. https://github.com/simple-salesforce/simple-salesforce/
2. https://github.com/john-kurkowski/tldextract

This also means all those libraries should be fixed/upgraded to using the latest version of requests. https://github.com/simple-salesforce/simple-salesforce/pull/228 is an attempt in that direction. But, this may not be scalable.

But, is it somehow possible to make the libraries using the older versions of requests agnostic of the changes to requests. Something like backward compatibility. This will greatly help people using those libraries.

What does the contributor community think of this ? Maybe there could be better ways of solving backward compatibility ?
Thanks !




`requests.certs.where()` has always existed. In more recent versions it's just `certifi.where` imported into that namespace.
Not recognized as Javascript browser

Hi,
first of all thank for your product.

I have written this code to navigate a website. 

```python
URLbase='http://albopretorio.comune.palermo.it/albopretorio'
from requests_html import BrowserHTMLSession
session = BrowserHTMLSession()

# open the first page
r = session.get('http://albopretorio.comune.palermo.it/albopretorio/jsp/home.jsp?modo=info&info=servizi.jsp&ARECOD=70&SERCOD=-1&sportello=albopretorio')

# open the second page
URL=URLbase+(link[0].attrs["href"])[2:]
r = session.get(URL)

# open the third page
URLMobilita=URLbase+(link[3].attrs["href"])[2:]
r = session.get(URLMobilita)

r.html.html
```

It works, but at the third opened URL, the website give me (in Italian) a warning related to javascript: "ATTENZIONE - Il browser in uso non supporta le applicazioni Javascript".

In english is something like "Warning- The browser in use does not support Javascript applications".

Is there a way to pass this kind of barrier?

Thank you

I'm closing there are some errors of mine
I would like to contribute.

Hey I have requests and I really love that and I would like to contribute and I think one way by which I can contribute is by type annotating the code base if this is something that I should do please help in getting started.

Hi @RatanShreshtha, thanks so much for reaching out about contributing! We've reviewed interest in adding type annotations directly in the Requests codebase, and [decided against it in the past](https://github.com/requests/requests/issues/3855#issuecomment-277931774). I think that is probably still the case now, but I'd highly encourage you to keep an eye out for other opportunities to contribute.

@nateprewitt I believe @kennethreitz wants to annotate the library for v3.0.0. I think he even has a branch where he's starting that work.

@sigmavirus24 How can I get started then?

check out https://github.com/requests/requests/tree/threedotoh
why conversion  `sys.modules` to list??

why conversion  `sys.modules` to list??
https://github.com/requests/requests/blob/master/requests/packages.py#L10


Hey @wsqy, thanks for the question. I don't know if there is a specific reason `sys.modules` was cast as a list other than to ensure it's iterable. It's likely something that slipped through during code review.

If we didn't, we'd end up modifying the object we're iterating and Python 3 would blow up. That's not idea. We also likely don't want to touch the items we are inserting into sys.modules.

This is not the place for questions of this type.
Add PURGE verb

Many packages have established PURGE as a defacto HTTP verb for flushing caches.
This implements the new verb.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=h1) Report
> Merging [#4522](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/6e76aaea4595d7c2a953fea5d624344e8c11f93a?src=pr&el=desc) will **decrease** coverage by `0.1%`.
> The diff coverage is `33.33%`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4522/graphs/tree.svg?width=650&token=mZGswIiXLa&height=150&src=pr)](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #4522      +/-   ##
==========================================
- Coverage   90.18%   90.07%   -0.11%     
==========================================
  Files          15       15              
  Lines        1548     1551       +3     
==========================================
+ Hits         1396     1397       +1     
- Misses        152      154       +2
```


| [Impacted Files](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/api.py](https://codecov.io/gh/requests/requests/pull/4522/diff?src=pr&el=tree#diff-cmVxdWVzdHMvYXBpLnB5) | `76% <33.33%> (-5.82%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=footer). Last update [6e76aae...b288862](https://codecov.io/gh/requests/requests/pull/4522?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Hey @val314159, thanks for putting this together and contributing to Requests! Unfortunately, Requests has a frozen API because we consider it mostly feature complete. You can see in [this section](http://docs.python-requests.org/en/master/user/advanced/#custom-verbs) of the documentation how to use custom verbs with Requests, which we've deemed sufficient for the time being. Hopefully that helps with your use case.
AttributeError: module 'requests' has no attribute 'SESSION'

I'm using MacOS
I installed requests using pip3
And I get
" AttributeError: module 'requests' has no attribute 'SESSION' "

% python3 --version
Python 3.5.3

## Reproduction Steps

```python
# login.py
import requests

session = requests.SESSION()
```

python3 login.py

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.1.4"
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.5.3"
  },
  "platform": {
    "release": "17.2.0",
    "system": "Darwin"
  },
  "pyOpenSSL": {
    "openssl_version": "1010007f",
    "version": "17.5.0"
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "9081df"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": true
}
```
Update MANIFEST.in

Hey !

As requests no longer uses 'requierements.txt' file to manage dependancies, I think we need to update MANIFEST.in to add 'Pipfile' and 'Pipfile.lock' instead of 'requirements.txt'.

Moreover, I've also noticed the 'NOTICE' file no longer exists too.

## Expected Result

MANIFEST.in : 

> include README.rst LICENSE HISTORY.rst pytest.ini Pipfile Pipfile.lock
> recursive-include tests *.py

## Actual Result

MANIFEST.in : 

> include README.rst LICENSE NOTICE HISTORY.rst pytest.ini requirements.txt
> recursive-include tests *.py
POST changed to GET when request got HTTP/3xx

A POST request changed to GET request when  the Request object got 3xx answer from server.

I don't know the RFC exactly, but the expected result would be that request repeat as POST at new URL.

Here is the code:
```
r = requests.post("http://foobar.com/script", data={'foo': 'bar'})
```

The server answer:

```
HTTP/1.1 302 Found
Date: Thu, 15 Feb 2018 10:42:16 GMT
Server: Apache/2.4.25 (Debian)
Location: https://foobar.com/script
Content-Length: 222
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
```

Then Request repeats the request as GET.

Debian Linux 9.3
Python3 (3.5.3)
Apache2.4 (the server where Request sends the request)

```
>>> requests.__version__
'2.12.4'
```
I've changed the url to https schema, then it works.

In the future, please search **closed and** open issues before creating new ones that are duplicates. 

Duplicate of #4251 
Duplicate of #4236 
Duplicate of #3915 

This behaviour protects you against Requests sending sensitive data to the wrong server, see also

- [CVE 2014-1829](http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1829)
- [CVE 2014-1830](http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1830)

@sigmavirus24 - thanks for feedback.

Sorry, next time I'll check the closed issues too.

Regards,
a.

In my own case, I reconfigured the server redirect using 307 instead of 301/302. This makes sure that request body and type is not tampered.

@m-bryo, thanks, I'll check out.
Hooks aren't called each time with retrying

Summary.

Hooks aren't called on each retry, only at the end of retrying

requests==2.18.4
requests-oauthlib==0.8.0

Is this intended functionality, how do I get a hook called on each retry? Here is my code 

```
retries = Retry(total=2,
                backoff_factor=0.1,
                status_forcelist=[404],
                raise_on_status=False
                )

self.gbdx_connection.mount(self.root_url, HTTPAdapter(max_retries=retries))

self.gbdx_connection.hooks['response'].append(refresh_token)
```


Using the `Retry` object means you're interacting with `urllib3`. Hooks are handled only in Requests. There's no plan to make hooks fire on retries inside of urllib3 when urllib3 doesn't have the concept of hooks.

@sigmavirus24 doh that makes sense
requests.exceptions.ConnectionError: HTTPConnectionPool

Summary.

## Expected Result
I am expecting the connection to be established with port 4000
What you expected.

## Actual Result

What happened instead.
File "/home/bl3-rqir-150-fi/inspection/url.py", line 20, in trigger_camera
    trigger_data = requests.get(self.url)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=4000): Max retries exceeded with url: /trigger_something/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa0100dea90>: Failed to establish a new connection: [Errno 111] Connection refused',))


## Reproduction Steps
It is not happening all the times, I am doing a httpPost to localport:4000. Multiple posts are done to this port but they are not simultaneous. 
```python
import requests

```

## System Information

    $ python -m requests.help

```
<paste here>
{
  "chardet": {
    "version": "3.0.4"
  }, 
  "cryptography": {
    "version": ""
  }, 
  "idna": {
    "version": "2.6"
  }, 
  "implementation": {
    "name": "CPython", 
    "version": "2.7.12"
  }, 
  "platform": {
    "release": "4.13.0-32-generic", 
    "system": "Linux"
  }, 
  "pyOpenSSL": {
    "openssl_version": "", 
    "version": null
  }, 
  "requests": {
    "version": "2.18.4"
  }, 
  "system_ssl": {
    "version": "1000207f"
  }, 
  "urllib3": {
    "version": "1.22"
  }, 
  "using_pyopenssl": false
}

```

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).

Without knowing what your actually doing, there's nothing we can do to help.

For example, if you're using a single-threaded server locally that can only handle one connection at a time and sending multiple requests to it simultaneously, of course you'll see this.

Since this seems to not actually be a Requests bug but instead a request for help, I'm closing this. Please use [StackOverflow](https://stackoverflow.com) for questions and support needs. This project reserves the issue tracker for defects and feature improvements.
Involving retry machinery causes `requests` to hide original cause of problem

I'm trying to better understand how retry machinery works, and how (and when) to use it in production environments. Some of my experiments leads me to realize the fact that involving retry machinery causes `requests` to _hide_ actual cause of problem occurred when retrying some request. I think, it is important to distinguish between not to sending request at all (`ConnectionError`) and sending request but not to receiving response (`ReadTimeout`, for example).

## Expected Result

When I retrying request with retry machinery involved, I expect it to raise appropriate exception when retrying is also failed.

## Actual Result

Seems like in such case the exception which will be raised is always `ConnectionError`.

## Reproduction Steps

```python
import logging

import requests
from urllib3.util import Retry

logging.basicConfig(format='%(asctime)s:%(levelname)s:%(name)s - %(message)s')
logging.getLogger().setLevel(logging.DEBUG)

adapter = requests.adapters.HTTPAdapter(max_retries=Retry(total=3))
session = requests.Session()
session.mount('https://', adapter)

session.get('https://httpbin.org/delay/3', timeout=2)
```
Received exception is `ConnectionError`, but actual cause of problem is `ReadTimeot`, see [retry.log](https://github.com/requests/requests/files/1707261/retry.log)


## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.1.4"
  },
  "idna": {
    "version": ""
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.4"
  },
  "platform": {
    "release": "4.14.17-50.current",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "100020ef",
    "version": "17.5.0"
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "100020ef"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": true
}
```


This reports in urllib3. The retry functionality is actually theirs.

But the logic of translating their exceptions (`ReadTimeoutError`) into `requests` exceptions belongs to `requests` itself. It is `requests` who raise wrong(?) exception, not `urllib3`.
Version 2.12.4 

Hi all , running kodi 16.1 , I keep getting an update for requests to version 2.18.4 but it keeps failing , currently I'm on version 2.12.4 , is the newer version only for a higher kodi version ?? Thanks 

If I recall correctly, `kodi` is not a directly supported platform. You need to talk to whomever is maintaining the package for that platform.
Minor

Fixed typos:
nonexistant -> nonexistent
neccessary -> necessary

# [Codecov](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=h1) Report
> Merging [#4507](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/654da610e1137246d9f5e5ccb9979bbfeffc6949?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4507/graphs/tree.svg?token=mZGswIiXLa&src=pr&height=150&width=650)](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #4507   +/-   ##
=======================================
  Coverage   90.18%   90.18%           
=======================================
  Files          15       15           
  Lines        1548     1548           
=======================================
  Hits         1396     1396           
  Misses        152      152
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=footer). Last update [654da61...5dd8507](https://codecov.io/gh/requests/requests/pull/4507?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


@SethMichaelLarson ah, sorry, reverted back
use dumb reason decoding on Python 2

Try to fix #4489 : Python 2.x IOError cannot handle unicode argument, and HTTPError is a IOError.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=h1) Report
> Merging [#4505](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/654da610e1137246d9f5e5ccb9979bbfeffc6949?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4505/graphs/tree.svg?width=650&token=mZGswIiXLa&height=150&src=pr)](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #4505      +/-   ##
==========================================
+ Coverage   90.18%   90.19%   +0.01%     
==========================================
  Files          15       15              
  Lines        1548     1550       +2     
==========================================
+ Hits         1396     1398       +2     
  Misses        152      152
```


| [Impacted Files](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/models.py](https://codecov.io/gh/requests/requests/pull/4505/diff?src=pr&el=tree#diff-cmVxdWVzdHMvbW9kZWxzLnB5) | `93.7% <100%> (+0.02%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=footer). Last update [654da61...bc0de4e](https://codecov.io/gh/requests/requests/pull/4505?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


I think we’re unlikely to fix this at this point given the usage of Python 2.7 and lack of activity on the PR.
Python2 vs Python3 octet-stream request error

Hello!
I am using requests to access some data from a localhost. When I run the code I have attached below on Python2, it seems to work perfectly, however when I switch to Python3, r.content displays a much larger octet_stream length string. Perhaps this is due to the data type being pulled by requests? Any recommendations? It seems requests is not consistent across Python2 and Python3

```import matplotlib.pyplot as plt
import requests
import numpy as np

def get_cutout(chan, res, xspan, yspan, zspan, api = "http://localhost:8000"):

    """
        ID MUST BE STRING ""
        xpix = "x" how many pixels traveled in x
        ypix = "y" how many pixels traveled in y
        zpix = "z" how many pixels traveled in z
        xo, yo, zo (x,y,z offsets)
        type = "raw"
        scale = "grayscale"
    """
    #Defining used variables
    chan = chan.split("/")
    UUID = chan[0]
    exp = chan[1]

    xpix = xspan[1]-xspan[0]
    print(xpix)
    xo = xspan[0]
    ypix = yspan[1]-yspan[0]
    yo = yspan[0]
    zpix = zspan[1]-zspan[0]
    zo = zspan[0]

    size = str(xpix) + "_" + str(ypix) + "_" + str(zpix)
    offset = str(xo) + "_" + str(yo) + "_" + str(zo)

    #User entered IP address with added octet-stream line to obtain data from api in octet-stream form
    #0_1_2 specifies a 3 dimensional octet-stream "xy" "xz" "yz"
    address = api + "/api/node/" + UUID + "/" + exp + "/raw/0_1_2/" + size + "/" + offset + "/octet-stream"
    r = requests.get(address)
    octet_stream = str(r.content)
    print(len(octet_stream))

     #Converts obtained octet-stream into a numpy array of specified type uint8
    block = np.fromstring(octet_stream, dtype = np.uint8)
    print(block.shape)
    
    #Specifies the 3 dimensional shape of the numpy array of the size given by the user
    volumeOut =  block.reshape(zpix,ypix,xpix)

    #Returns a 3-dimensional numpy array to the user
    return volumeOut

def get_channel(UUID, coll, exp):
    """
        Method to input all channel hierarchy requirememnts, works as a dummy
        for BossRemote Parallelism.

        Args:
            UUID (str) : Root UUID of the repository
            col (str) : Name of collection
            exp (str) : Name of experiment

        Returns:
            chan (str) : String of UUID/col/exp
    """

    chan = UUID + "/" + coll + "/" + exp
    return chan

UUID = "30eb"
volumeD = get_cutout(
    get_channel(UUID, "dyer15_3_maskim_DUmmy", "dyer15_3_maskim_DUmmy"), 0,
    [0,2560], [0,2560], [290,292]
)

```

Hey @lrodri29, this has to do with your use of string casting. A “str” in python 2 is a bytes representation of the data, in python 3 it’s a utf-8 encoded string. This is almost certainly what’s causing the variance. I’d perform your check on the raw r.content rather than the str wrapped value.

I’m going to close this for now since it’s known behavior with the python programming language and not behavior of Requests. Please feel free to reopen this if you believe there is still a bug here. Thanks!

Edit: mobile autocorrect 😬
cannot import name set_file_position  

Summary.

## Expected Result

```
python > import requests > working 
```

## Actual Result

```
$ python                                       
Python 2.7.14 (default, Dec 11 2017, 16:08:01)                                                 
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux2                                               
Type "help", "copyright", "credits" or "license" for more information.                         
>>> import requests                            
Traceback (most recent call last):             
  File "<stdin>", line 1, in <module>          
  File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 60, in <module>           
    from .packages.urllib3.exceptions import DependencyWarning                                 
  File "/usr/lib/python2.7/site-packages/requests/packages/__init__.py", line 29, in <module>  
    import urllib3                             
  File "/usr/lib/python2.7/site-packages/urllib3/__init__.py", line 8, in <module>             
    from .connectionpool import (              
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 39, in <module>      
    from .util.request import set_file_position                                                
ImportError: cannot import name set_file_position    
```
## Reproduction Steps

```python
import requests
```

## System Information
```
    $ $ python -m requests.help
/usr/bin/python: cannot import name set_file_position
```


@ror6ax [set_file_position](https://github.com/shazow/urllib3/blob/d9898fb39e6c6037dea12d7226813d35b40f0947/urllib3/util/request.py#L77) definitely exists in urllib3. It appears you have an outdated version of urllib3, so I suggest updating to 1.22.

Since this seems to be a request for help rather than a defect in Requests, can you please open a question on [StackOverflow](https://www.stackoverflow.com) with any further questions and we can look at getting things resolved there. Thanks!
Separate collections from collections.abc

In Python 3.7, there is a warning that the abstract bases in collections.abc will no longer be accessible through the regular collections module in Python 3.8.  This patch future-proofs requests.

I wasn't able to run the test suite locally, so this needs a thorough test going forward.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=h1) Report
> Merging [#4501](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/8da118dfeb15989c47241d6ad6b7c429a34a51f3?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4501/graphs/tree.svg?height=150&width=650&token=mZGswIiXLa&src=pr)](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #4501      +/-   ##
==========================================
- Coverage   90.18%   90.15%   -0.03%     
==========================================
  Files          15       15              
  Lines        1548     1544       -4     
==========================================
- Hits         1396     1392       -4     
  Misses        152      152
```


| [Impacted Files](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/models.py](https://codecov.io/gh/requests/requests/pull/4501/diff?src=pr&el=tree#diff-cmVxdWVzdHMvbW9kZWxzLnB5) | `93.66% <100%> (-0.02%)` | :arrow_down: |
| [requests/cookies.py](https://codecov.io/gh/requests/requests/pull/4501/diff?src=pr&el=tree#diff-cmVxdWVzdHMvY29va2llcy5weQ==) | `77.02% <100%> (-0.1%)` | :arrow_down: |
| [requests/structures.py](https://codecov.io/gh/requests/requests/pull/4501/diff?src=pr&el=tree#diff-cmVxdWVzdHMvc3RydWN0dXJlcy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [requests/sessions.py](https://codecov.io/gh/requests/requests/pull/4501/diff?src=pr&el=tree#diff-cmVxdWVzdHMvc2Vzc2lvbnMucHk=) | `95.62% <100%> (-0.02%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=footer). Last update [8da118d...15e1139](https://codecov.io/gh/requests/requests/pull/4501?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


This branch is also out-of-date with master and will need to be updated

Hey @rhettinger, would you mind rebasing this onto current master? Assuming @sigmavirus24 doesn't have further issues, I think we're set to merge this.
Remove requests.packages for v3.0.0

As v3.0.0 already includes other backwards incompatible changes, it is a good time to remove the old entry point for vendored packages. Cleans up compatibility shims.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=h1) Report
> Merging [#4500](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=desc) into [proposed/3.0.0](https://codecov.io/gh/requests/requests/commit/a58b1e66cbf6479cdf57ef4c4b1e57b1e3176daa?src=pr&el=desc) will **decrease** coverage by `0.03%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4500/graphs/tree.svg?token=mZGswIiXLa&src=pr&height=150&width=650)](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=tree)

```diff
@@                Coverage Diff                 @@
##           proposed/3.0.0    #4500      +/-   ##
==================================================
- Coverage           90.54%   90.51%   -0.04%     
==================================================
  Files                  15       14       -1     
  Lines                1555     1549       -6     
==================================================
- Hits                 1408     1402       -6     
  Misses                147      147
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=footer). Last update [a58b1e6...4c6d9e1](https://codecov.io/gh/requests/requests/pull/4500?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Hey @jdufresne, I'd like to get master merged into the 3.0.0 branch before we merge this in, just so we're sure we have everything covered. I'll try to get that done tomorrow and then you'll need to rebase this commit.

✨🍰✨
Remove remaining references to removed, vendored packages

As the vendored packages were removing in version 2.16, all remaining
doc references should be replaced with newer practices.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=h1) Report
> Merging [#4499](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/cafa3c16c261066c01d7f5699ff0172fc1a605af?src=pr&el=desc) will **increase** coverage by `0.9%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4499/graphs/tree.svg?width=650&token=mZGswIiXLa&height=150&src=pr)](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master    #4499     +/-   ##
=========================================
+ Coverage   89.27%   90.18%   +0.9%     
=========================================
  Files          15       15             
  Lines        1548     1548             
=========================================
+ Hits         1382     1396     +14     
+ Misses        166      152     -14
```


| [Impacted Files](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/help.py](https://codecov.io/gh/requests/requests/pull/4499/diff?src=pr&el=tree#diff-cmVxdWVzdHMvaGVscC5weQ==) | `68.62% <100%> (ø)` | :arrow_up: |
| [requests/adapters.py](https://codecov.io/gh/requests/requests/pull/4499/diff?src=pr&el=tree#diff-cmVxdWVzdHMvYWRhcHRlcnMucHk=) | `93.11% <0%> (+0.45%)` | :arrow_up: |
| [requests/sessions.py](https://codecov.io/gh/requests/requests/pull/4499/diff?src=pr&el=tree#diff-cmVxdWVzdHMvc2Vzc2lvbnMucHk=) | `95.63% <0%> (+0.72%)` | :arrow_up: |
| [requests/models.py](https://codecov.io/gh/requests/requests/pull/4499/diff?src=pr&el=tree#diff-cmVxdWVzdHMvbW9kZWxzLnB5) | `93.67% <0%> (+2.25%)` | :arrow_up: |
| [requests/\_internal\_utils.py](https://codecov.io/gh/requests/requests/pull/4499/diff?src=pr&el=tree#diff-cmVxdWVzdHMvX2ludGVybmFsX3V0aWxzLnB5) | `100% <0%> (+6.25%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=footer). Last update [cafa3c1...a6b9c87](https://codecov.io/gh/requests/requests/pull/4499?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Rebased to resolve conflicts.
Trim trialing white space throughout the project

Many editors clean up trailing white space on save. By removing it all in one go, it helps keep future diffs cleaner by avoiding spurious white space changes on unrelated lines.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=h1) Report
> Merging [#4498](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/8da118dfeb15989c47241d6ad6b7c429a34a51f3?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4498/graphs/tree.svg?width=650&height=150&src=pr&token=mZGswIiXLa)](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #4498   +/-   ##
=======================================
  Coverage   90.18%   90.18%           
=======================================
  Files          15       15           
  Lines        1548     1548           
=======================================
  Hits         1396     1396           
  Misses        152      152
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=footer). Last update [8da118d...e8205c0](https://codecov.io/gh/requests/requests/pull/4498?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Hey @jdufresne, looks like this needs a rebase, then I think we'll be set.

Rebased.
Clarify docs that Requests always uses certs from certifi

Since commit 0d7de6430eef0cf09f9662746daf0c28d83f144e, certifi is always used for certificates. Certify became a hard dependency of the package in 628633143d5b8590b1dbdf5371fe81fb8250dffd.

Now update the docs to clarify that Request will always use certificates from certifi.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=h1) Report
> Merging [#4497](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/3c1d36b827417fdeaf5a1c106129de30dac371d7?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4497/graphs/tree.svg?width=650&height=150&src=pr&token=mZGswIiXLa)](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #4497   +/-   ##
=======================================
  Coverage   90.18%   90.18%           
=======================================
  Files          15       15           
  Lines        1548     1548           
=======================================
  Hits         1396     1396           
  Misses        152      152
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=footer). Last update [3c1d36b...9c0db92](https://codecov.io/gh/requests/requests/pull/4497?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Hey @jdufresne, thanks for updating the docs! I think this is good for the current version of Requests. I do wonder if we may want some historical information though. Noting this changed with the release of 2.16 and leaving a small blurb on how it worked prior may be helpful.

I added the suggested blurb. Let me know what you think. I'm happy to tweak or reword if you think it could be improved. Thanks.

Updated to remove suggested lines. Thanks.

Rebased to resolve merge conflicts.
Pass kwargs from adapter send call to add_headers, per documentation

The docstring for `HTTPAdapter.add_headers` implies that keyword args from the `send` call will be passed into `add_headers` – this change passes them in.  This would be helpful, particularly for kwargs like `timeout`, which may influence the headers that need to be added by an `HTTPAdapter` subclass.

# [Codecov](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=h1) Report
> Merging [#4496](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=desc) into [master](https://codecov.io/gh/requests/requests/commit/512066488e039e048ff255d8322fbb53642166bd?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/requests/requests/pull/4496/graphs/tree.svg?height=150&width=650&token=mZGswIiXLa&src=pr)](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #4496   +/-   ##
=======================================
  Coverage   90.18%   90.18%           
=======================================
  Files          15       15           
  Lines        1548     1548           
=======================================
  Hits         1396     1396           
  Misses        152      152
```


| [Impacted Files](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/adapters.py](https://codecov.io/gh/requests/requests/pull/4496/diff?src=pr&el=tree#diff-cmVxdWVzdHMvYWRhcHRlcnMucHk=) | `93.11% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=footer). Last update [5120664...8e04052](https://codecov.io/gh/requests/requests/pull/4496?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


This looks reasonable. Thanks @jonblum
InvalidSchema should be InvalidScheme

Summary.

## Expected Result

If requests cannot determine what *scheme* a URL has it should report this clearly.

## Actual Result
```
InvalidSchema at /scrapyd/start-job/
No connection adapters were found for 'localhost:6800/schedule.json'
```

There is no such thing as a URL "schema". 

https://tools.ietf.org/html/rfc3986
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

The words "schema" and "scheme" are distinct.  "Schema" is the singular of "schemata".  The plural of "scheme" is "schemes" or "schemas". (https://english.stackexchange.com/questions/9232/plural-of-scheme)  Given that SQL uses the word schema this is an extremely confusing error message.

Hey @kurtbrose, thanks for pointing this out. We’ve actually already patched this in #2961 but in the 3.0.0 branch due to this being a breaking change. The corrected naming will be available once the Requests team is ready to proceed with releasing 3.0.0.
Deprecation Warning on Python 3.7 beta

~/requests/models.py:170: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  if isinstance(hook, collections.Callable):

I created a venv in Python 3.7 and got the warning when using pip.


Thanks for the report @csabella, we’re just starting to test against 3.7 so there’s likely some of these that haven’t been caught yet. This should be relatively simple to fix, so we can make sure this is adjusted before 3.7 is officially released.

Resolved in #4501.