Raibek/requests-github-issues huggingface dataset:
Response Cookies are not Accessible (but they end up in the session)

`response.cookies` is empty when it shouldn't; [the example in documentation for reading cookies from a response](https://requests.readthedocs.io/en/master/user/quickstart/#cookies) does not seem to work.

*(**EDIT:** solved, it works, see answer below)*

## Expected Result

```
>>> requests.get('https://httpbin.org/cookies/set?foo=bar').cookies
<RequestsCookieJar[Cookie(version=0, name='foo', value='bar', port=None, port_specified=False, domain='httpbin.org', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False)]>
```

## Actual Result

```
>>> requests.get('https://httpbin.org/cookies/set?foo=bar').cookies
<RequestsCookieJar[]>
```

Note that we can see the cookie in the session if we use one, though:

```
>>> s = requests.session()
>>> resp = s.get('https://httpbin.org/cookies/set?foo=bar')
>>> s.cookies
<RequestsCookieJar[Cookie(version=0, name='foo', value='bar', port=None, port_specified=False, domain='httpbin.org', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False)]>
>>> s.cookies['foo']
'bar'
>>> resp.cookies
<RequestsCookieJar[]>
```

## Reproduction Steps

```python
import requests
print(requests.get('https://httpbin.org/cookies/set?foo=bar').cookies)
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.4"
  },
  "platform": {
    "release": "5.4.0-48-generic",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.24.0"
  },
  "system_ssl": {
    "version": "1010106f"
  },
  "urllib3": {
    "version": "1.25.9"
  },
  "using_pyopenssl": false
}
```


Check `response.history` the cookies are set on the response that actually received the cookies, not every subsequent one.

Indeed:

```
>>> resp.history
[<Response [302]>]
>>> resp.history[0].headers
{'Date': 'Thu, 15 Oct 2020 15:33:54 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '223', 'Connection': 'keep-alive', 'Server': 'gunicorn/19.9.0', 'Location': '/cookies', 'Set-Cookie': 'foo=bar; Path=/', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true'}
>>> resp.history[0].cookies
<RequestsCookieJar[Cookie(version=0, name='foo', value='bar', port=None, port_specified=False, domain='httpbin.org', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False)]>
```

Thanks.
README mentions Python 2.7 support

_(Bug template was not applicable)_

The README states that requests officially supports Python 2.7. Shouldn't that support be dropped now that Python 2 has been sunset?

Hi @Helveg, the documentation is correct. There are still a number of tools that use Requests and require Python 2.7 support, including pip. Our support may change as we get into 2021 but we'll provide advanced notification on that.
Keep-alive after pickling a session

I'm trying to implement TLS session resumption for my command line application.

This issue https://github.com/psf/requests/issues/2522 explains how to pickle a `requests.session`. 

However, the TLS handshake is repeated when I rerun my application, loading a pickled session.

I was wondering what I'm I missing?


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.
RESPONSE 500 on Heroku

On Heroku and localhost 
![image](https://user-images.githubusercontent.com/65137814/95205064-8aaa6b00-07ed-11eb-89a9-2b48ffaec2d6.png)
![image](https://user-images.githubusercontent.com/65137814/95205071-8da55b80-07ed-11eb-9c75-264f90f12947.png)

Response 200 (on localhost) its good
Response 500 (on Heroku) its BAD. How fix it?

url = 'https://animego.org/anime/filter/status-is-released/apply?&direction=desc&page='
headers = {
                'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.90 Safari/537.36,', 'Origin': 'http://example.com', 'Referer': 'http://example.com/some_page'}
            response = requests.request("get", url, headers=headers)
            print(response)
            


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.
Docs and Readme: [GitHub] Deprecation Notice

I've followed the main example you present at the start of your Docs

```python
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.encoding
'utf-8'
>>> r.text
'{"type":"User"...'
>>> r.json()
{'private_gists': 419, 'total_private_repos': 77, ...}
```
and I've received the following **[GitHub] Deprecation Notice**:

>On October 6th, 2020 at 11:19 (UTC) you used a password to access an endpoint through the GitHub API using python-requests/2.18.4:
>
>https://api.github.com/user
>
>Basic authentication using a password to the API is deprecated and will soon no longer work. Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth/ for more information around suggested workarounds and removal dates.
>
>Thanks,
>The GitHub Team


The example code is not broken. GitHub is just changing their policies around using basic authentication. This could be changed to something else easily. GitHub's deprecation is not a bug in our project though.
Support for SameSite cookie flag.

Hi,

Have you any plan to expose `samesite` cookie flag?


We use the standard library which doesn't expose it but I'm working on [moreos](/sigmavirus24/moreos) which will have a cookie jar that's saner, more secure, and would expose this for Requests as a drop-in replacement

You are right, but I think it's possible to add to newer python versions. I added it to my fork for my use case.

https://github.com/anio/requests/commit/ae838c9741e39d53dea780d72137dfc4ad048b04

Newer python versions aren't all we support and further, don't have a samesite attribute here
requests.get(url, proxies=proxy_list), Failed to parse if username is Email

Hey at all.

I have an Issue with request.get to use proxies function if the username for the proxy server contains an @ or some "unsafe characters".

## Expected Result

To get successfully logged in to my proxy and get the IP from proxy server

## Actual Result

Failed to parse: https://username@email.com:password@proxy.com

## Reproduction Steps

```python
import requests
proxys = {
        'http': "http://username@email.com:password@proxy.com,
        'https': "https://username@email.com:password@proxy.com,
    }
requests.get("https://www.wieistmeineip.at/", proxies=proxys)
```

## System Information

    $ python -m requests.help

{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "3.1"
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.5"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "1010107f",
    "version": "19.1.0"
  },
  "requests": {
    "version": "2.24.0"
  },
  "system_ssl": {
    "version": "1010108f"
  },
  "urllib3": {
    "version": "1.25.10"
  },
  "using_pyopenssl": true
}


In RFC 3986 `@` is exclusively reserved for separating the user info from the hostname in the authority section (`authority = userinfo @ host : port`) so you should replace `@` with `%40`. This has been covered in open and closed issues and is likely well documented on stackoverflow.
BUG "except requests.HTTPError as e:" at error 500 doesnt work

Hi! 
This expect doesnt work with error 500

`except requests.HTTPError as e:`

Why did you do that? Do you like the difficulty? 

It should be noted that the success of the call to r.json() does not indicate the success of the response. Some servers may return a JSON object in a failed response (e.g. error details with HTTP 500). Such JSON will be decoded and returned. To check that a request is successful, use r.raise_for_status() or check r.status_code is what you expect.


So what's the point?  `except requests.HTTPError as e:`


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.
Multi post request in Session doesn't use single connection

I use session object to make the request, but I see the connection will be close after the request, because I see the client sent the tcp-FIN flag to the server by wireshark.

-------------
python 3.7.7
requests 2.24.0
win10

We send `Connection: keep-alive` but we can't control the server. This isn't a requests bug and you've provided none of the required informatoin

I found a information, open the logging, it print something:

DEBUG:urllib3.connectionpool:Resetting dropped connection: (this is a ip)

in two same post request. 
@sigmavirus24 

I'll reiterate one last time, @chenhd - this is not a requests bug.

Read up on the TCP state machine and how the fact that the server itself is closing the socket. We can't reuse a closed connection.

I've locked this because this is resolved and you've not been respectful of the project's time by neither filling out the template nor understanding that this isn't a bug and continuing to comment here
How can I create requests without actually executing them ( to get instance )

I want to do this in order to log the requests myself, in order to reproduce them when an error is thrown, for better debugging.

If there is no way to do so how can I log the requests ( all http requests: GET, POST, PUT,..) preferably as cURL string

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.
Exception instead of following 302 redirect

Requests throw an exception instead of following 302 redirect. Curl returns a response and browsers follow redirect.

## Expected Result

Requests follow redirect

## Actual Result

Exceptions is thrown:
```
ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a70874e50>: Failed to establish a new connection: [Errno 111] Connection refused'))
```

## Reproduction Steps

```python
import requests
requests.get("http://localhost:8000/")
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.5"
  },
  "platform": {
    "release": "4.19.76-linuxkit",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.24.0"
  },
  "system_ssl": {
    "version": "1010104f"
  },
  "urllib3": {
    "version": "1.25.10"
  },
  "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).


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.

> [Errno 111] Connection refused

Implies the server refused your connection. This isn't a Requests issue
Setting SSLContext for Session or operation

The `certifi` library often runs into issues with domain certificates, but in the standard `urllib.request` library has no issue. 

If I set the context to use the certifi's file, I get the SSL error, 

```python
import ssl
import certifi
import requests.urllib as urlrq

resp = urlrq.urlopen(url="https://<web address>/rest/info?f=json", 
                                  context=ssl.create_default_context(cafile=certifi.where()))
```

if I use the standard library and set the context as follows:

```python
import ssl
import certifi
import requests.urllib as urlrq

resp = urlrq.urlopen(url="https://<web address>/rest/info?f=json", 
                                  context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
```

No SSL error.

How can I get requests to honor this `SSLContext`?  



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.

It's actually a usage question for the API, stackoverflow isn't the best place to get help.

It's a "How do I use this?" which is exactly the type of every `python-requests` question on StackOverflow

https://stackoverflow.com/questions/64063235/how-to-use-sslcontext-with-python-requests-library

I left an answer on your question. Closing this now.
Fix no_proxy and no, not being respected. Merge self.proxies and proxies

Since no_proxy is not working as intended, I tried fixing it with least intrsion into whole process.
It is contained to the `merge_environment_settings` and `request` function. In the `request` the proxy from request and proxy from session are merged. Having the request proxy overwrite the session proxy where needed.

The  `should_bypass_proxies` is applied outside `get_environ_proxies` in `merge_environment_settings`, since `no_proxy` is only applied to OS ENV and not the proxies set in `requests` or `Sessions`

Should close #4871, I hope.

This patched fixed #5731 for me. I was very surprised this patch has not gotten any attention yet. Is there anything missing before it can be considered?

Hi @Suika and @RichieB2B, we are also dealing with this issue, any updates?

I found a work around that I described at https://github.com/psf/requests/issues/5731#issuecomment-1162215349 and in #6172 



Hi, we are also being hit by that and would appreciate if this issue would be fixed.

Also being hit by this; in our case it's setting `proxies` on the Session instance, but then the call to `proxies = merge_settings(...)` basically doesn't respect `should_bypass_proxy()` because it happens later.

@Suika thank you for your work

> any updates?

this issue is known for at least 5 years (#4871)
so i would not wait for "maintainers" to merge this patch

in general, waiting for pypi releases is a bad habit
just add this fork as a git module in `vendor/requests`
use `sys.path.append("vendor/requests/src")` and get on with life...


LGTM, im working for corp env, when setting up a Windows proxy, the 'no' and 'no_proxy' are fail in requests.get('http://localhost:8000', proxies={'http': proxy, 'https': proxy, 'no': 'localhost, 127.0.0.1'})
![image](https://github.com/psf/requests/assets/65639657/f182566c-20f4-46e8-aabf-6ec5c342d26d)
![image](https://github.com/psf/requests/assets/65639657/8fdff2f1-063b-4587-ad7d-7dcbb1be7b61)
The Post request route does not work for this library 

Summary.

## Expected Result

What you expected.

## Actual Result

What happened instead.

## Reproduction Steps

```python
import requests

```

## System Information

    $ python -m requests.help

```
<paste here>
```

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.
My kanboard is locked with an error - Internal Error: Identifier "container" is not defined.

My kanboard is locked with an error - Internal Error: Identifier "container" is not defined.

__Originally posted by @plyaskin in https://github.com/CoMPaTech/kanboard_plugin-done_column_highlight/issues/1__

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.
multipart/form-data request preparation possible issues

I've been trying to send a POST multipart/form-data request using the following function

```python
def upload_file(token, filepath, table_id):
    url = "https://h.app.wdesk.com/s/wdata/prep/api/v1/file"
    headers = {
        "Authorization": f"Bearer {token}",
    }
    files = {
        "file": open(filepath, "rb"),
        "tableId": (None, table_id)
    }
    resp = requests.post(url, headers=headers, files=files)
    print(resp.request.headers)
    return resp.json()
```

## Expected Result

Status 201 created JSON response.

## Actual Result

Status 400, with error message that contentType is missing from the request headers.
If `Content-Type` is added explicitly in the headers as `multipart/form-data` the response is a Status 500, unknown error.

Running the same request in NodeJS and with Postman don't produce these errors. 

## Reproduction Steps

N/A since invoking the API requires an auth token.

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.9"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.2"
  },
  "platform": {
    "release": "5.4.0-47-generic",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.23.0"
  },
  "system_ssl": {
    "version": "1010100f"
  },
  "urllib3": {
    "version": "1.25.7"
  },
  "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).


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.

Try examining your request with Wireshark to see exactly what's getting sent over the wire compared to other HTTP clients. This likely isn't a defect with Requests.
raise InvalidSchema("No connection adapters were found for {!r}".format(url)) pip._vendor.requests.exceptions.InvalidSchema: No connection adapters were found for 'javascript: void(0)'

import unittest
from datetime import datetime
from pip._vendor import requests
from selenium import webdriver


class Index(unittest.TestCase):
    @classmethod
    def setUpClass(cls) :
        chrome_options = webdriver.ChromeOptions()
        #chrome_options.add_argument('headless')
        #prefs = {"profile.default_content_setting_values.notifications": 2}
        #chrome_options.add_experimental_option("prefs", prefs)
        #chrome_options.add_argument("start-maximized")
        cls.driver = webdriver.Chrome(chrome_options=chrome_options,
                                      executable_path=r'/home/sharan/Desktop/chromedriver')
        cls.driver.maximize_window()

    def test_all_links_test(self):
        now = datetime.now()
        date_time = now.strftime("%m%d%Y%H%M%S")
        pageUrl = "https://www.amazon.in/dp/B01EU2M62S/"
        driver = self.driver
        driver.get(pageUrl)
        links = []
        elems = self.driver.find_elements_by_xpath("//a[@href]")
        for elem in elems:
            #href = [requests.head(elem.get_attribute("href"))]
            href = [elem.get_attribute("href")]
            page = requests.get(href)
            #print(elem.get_attribute('href'), href.status_code)
            print(page)
            links.append(href)
        file1 = open("/home/sharan/Desktop/flowace1/"+ date_time + ".xlsx", "x")
        file1.write("\n".join(links))
        file1.close()

    @classmethod
    # def tearDown(self):
    def tearDownClass(cls):
        cls.driver.close()
        print("jao")

if __name__== "main":
   # unittest.main(testRunner=HTMLTestRunner.HTMLTestRunner(output = "home/sharan/Desktop/Testing/Reports/"))
    unittest.main()
    #file1 = open("/home/sharan/Desktop/Testing/Reports/1.html", "x")
    #unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output=file1))



Hi @souravsharan97,

There's a couple issues here. You're importing a very old version of requests from a package private vendoring in pip. This is a *very* bad idea for stability in your code. I'd recommend installing Requests and updating to the latest version. Secondly, you can't pass calls to javascript into Requests, as they are not http URIs. If you have further questions about usage, please open an issue on StackOverflow. Thanks!
About proxy

Accodring to the document about proxy should like this:
proxies = {"http":"http://ip:port"},
but if i wrote like this :
proxies = {"http":"ip+port"}
some url also can got the response, but not all urls,
I think should ban like this  proxies = {"http":"ip:port"} so as to achieve unity.

I think you should try like this ( http://address : port )  it is possibly work.
Seems `requests.packages` is not installed, please install and try again!

I am running idcssearch binaries that seems calling requests but somehow its not present in virtual python word. multiple times I tries uninstall and install but no results. 


[sswarnka@sswarnka-linux idcs-tools]$ python
Python 2.7.5 (default, Nov 27 2019, 09:57:45) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import request
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named request
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/requests-2.24.0-py2.7.egg/requests/__init__.py", line 43, in <module>
    import urllib3
ImportError: No module named urllib3
>>> 


## System Information

    $ python -m requests.help
[sswarnka@sswarnka-linux idcs-tools]$ python -m requests.help
/usr/bin/python: No module named urllib3
[sswarnka@sswarnka-linux idcs-tools]$ 

[sswarnka@sswarnka-linux idcs-tools]$ pip3 freeze 
certifi==2020.6.20
chardet==3.0.4
freeze==3.0
idna==2.10
requests==2.24.0
six==1.15.0
urllib3==1.25.10
[sswarnka@sswarnka-linux idcs-tools]$ 

```
<paste here>
```

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).

Your `python` is Python2, but you are using `pip3`, the Python3 version of pip, to show your installed packages. Take a look at the output of `python -m pip freeze`.

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.
Redirection Code 308 (Permanent Redirect - POST to POST)

Hi,

Not a request for help but a suggestion to the project team to review [RFC 7538](https://tools.ietf.org/html/rfc7538).

It would be awesome to have redirection code 308 (POST to POST) implemented in a future Requests release.

Thanks!

@sartigas the issue is that as a client we can't know which servers reasonably support this as the majority of the web and a significant number of servers/applications pre-date this (relatively) recent RFC.

Hi @sartigas,

Just to clarify, are you asking about implementing redirect caching for a 308 response? Outside of that, 307 and 308 should operate to spec for redirects already.

Also, we tried some naive caching and it introduced way too many side-effect issues

> Also, we tried some naive caching and it introduced way too many side-effect issues

Yeah, that's what I've seen by looking into some old threads. I stumbled upon the dreaded 301 POST -> GET redirection and didn't find a straight solution that's why I went a step further and found RFC 7538. I'll give this a try tweaking the source code in a test server.

Thanks! appreciate your inputs.

Yeah, caching has generally been problematic for Requests, so I think it's unlikely we'd implement any more.

> I stumbled upon the dreaded 301 POST -> GET redirection and didn't find a straight solution that's why I went a step further and found RFC 7538.

301, 302, and 303 will all downgrade POST -> GET and strip the headers/body from the request. We've explicitly marked 307 and 308 to ignore this functionality though, so you should be safe there if your server starts returning that status code.

It sounds like you've got a path forward, so I'll close this for now. Feel free to reopen this if you're finding the above isn't working as described.
Special characters getting replaced using `params` keywarg

Special characters are getting replaced when sending them through the `params` kwarg. The same result occurs on mac and pc. Tested with the `get` and `post` methods.

## Expected Result

For the string to be added to the url as it was given to the requests module.

## Actual Result

Special characters getting replaced. Here are output some examples.

input: `email='kevin@test.com'`
output: `/cart?email=kevin%40test.com`

input: `email='kevin%test.com'`
output: `/cart?email=kevin%25test.com`

input: `email='kevin&test.com'`
output: `/cart?email=kevin%26test.com`

## Reproduction Steps

```python
import requests

url = url_factory()
params = {'email': 'kevin@test.com'}
response = session.post(url=url, params=params)

```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.1"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.24.0"
  },
  "system_ssl": {
    "version": "1010104f"
  },
  "urllib3": {
    "version": "1.25.10"
  },
  "using_pyopenssl": false
}
```

Hi @ktoldham,

This is the correct behavior for URI queries. You can read the full specification in [RFC 3986 section 3.4](https://tools.ietf.org/html/rfc3986#section-3.4). Those characters are required to be percent encoded before sending them across the network.

If you *must* violate that for some reason, you can use the [PreparedRequest](https://requests.readthedocs.io/en/master/api/#requests.PreparedRequest) workflow to modify your final parameters before sending. We'd discourage this though and recommend fixing the recipient if you have control of the receiving service.

Ah, gotcha. Ok, I'll get in touch with my devs. Thanks for the quick answer!
[DOCS] Quickstart Cookies link doesn't exist

On https://requests.readthedocs.io/en/master/user/quickstart/ clicking on `Cookies` in `Table of Contents` does nothing. It doesn't link to anything. `Cookies` part is completely missing in documentation.

## Expected Result

`Cookies` documentation to be present in the quickstart guide as described in `Table of Contents`.
https://requests.readthedocs.io/en/master/user/quickstart/#cookies links to `Cookies` part of the `Quickstart`.

## Actual Result

`Cookies` part is completely missing in documentation.
Links to the beginning of the page or does nothing.


I just tried clicking on the links that you posted to see what you were referring to, but they seem to work just fine. Both the "Cookies" link in the table of contents and the https://requests.readthedocs.io/en/master/user/quickstart/#cookies permalink work.

> I just tried clicking on the links that you posted to see what you were referring to, but they seem to work just fine. Both the "Cookies" link in the table of contents and the https://requests.readthedocs.io/en/master/user/quickstart/#cookies permalink work.



Hi @RomanKornev,

The anchor for "cookies" definitely exists in the page returned at https://requests.readthedocs.io/en/master/user/quickstart/#cookies. Beyond that anchor, this functionality is dictated by your browser and I'm unable to replicate the issue on any major browser. I'd ensure your browser is working correctly and perform any updates if needed.



@nateprewitt Thanks for confirming that it works! 
I found the problem: it was the `uBlock Origin` Chrome extension. Seems that by default it was blocking Cookies content.
What I was seeing until I clicked `Disable cosmetic filtering on this site`:
![image](https://user-images.githubusercontent.com/5807561/93124704-b0eb5800-f6d2-11ea-9bab-17237d8a58dc.png)
ValueError: invalid literal for int() with base 16: b''

Summary.

I am just trying to make a http request on a certain website, the thing is I am making requests for a lot of website and I am doing it in a for loop and that error on the title SOMETIMES shows up! YES SOMETIMES! there would be times that it occurs and not


What you expected.

Expect to have a good result

What happened instead.

This is what happened
![image](https://user-images.githubusercontent.com/55988471/92898416-8ab68580-f450-11ea-81c2-79b506bfbf29.png)


```python
#My Python version is 3.8.2

import requests
url = "somesite.com"
r = requests.get(url)


```

## System Information

    $ python -m requests.help

```
<paste here>
```

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).


By the way this is my version of the requests library 

![image](https://user-images.githubusercontent.com/55988471/92898892-f0a30d00-f450-11ea-8343-896f0a32d528.png)


i have also read some fixes from other people here is the site

https://github.com/psf/requests/issues/4248

There is a guy here that has the solution but I was thinking that maybe the developers could have another which is of course the developers are the one that I am going to consider first...

Please I needed this badly Thank you!

Your server is sending chunked data without following the HTTP specification. Nothing here to be fixed as the actual error you're encountering is the Incomplete read exception at the bottom of your screenshot (which isn't friendly for future folks searching or using screen readers).


There is definitely need to be fixed I think cause some people experience this too... They have provided solutions on it I was just thinking if the devs can somehow make a way through this?

https://github.com/psf/requests/issues/4248

Nope. I'm a former dev and I can promise there's no solution to broken servers

Then thanks to this guy right here cause a random guy just fixed everything 

https://github.com/psf/requests/issues/4248

To be clear, this isn't a universal fix. It will cause breakages elsewhere for valid use cases, so urllib3 can't implement this fix. I'm going to resolve this since it's not a defect in Requests but in the external server implementation.
requests prase http headers error

requests not fully parsed the http headers when there was two reponse line,as follows:
```
GET /cgi-bin/get_jpeg?ch=1 HTTP/1.1
Host: 121.156.161.92
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive

HTTP/1.0 200 OK
Date: Tue, 08 Sep 2020 13:17:53 GMT
Server: Boa/0.94.13
Connection: close
HTTP/1.0 200 OK
Connection: close
Content-Length: 77240
Content-Type: image/jpeg

xxxxx
```
requests parse result:
```
{'Date': 'Tue, 08 Sep 2020 13:20:16 GMT', 'Server': 'Boa/0.94.13', 'Connection': 'close'} 200
```

Requests doesn't parse this - httplib does in standard python. Please open a bug on bugs.python.org

I'll note this is also invalid HTTP. Server is not allowed to send multiple non-1XX responses from a single request.
Crawling a web miss a # in url,and then fail,how to resolve it?

Summary.

## Expected Result

Don't lose the charts after #  

## Actual Result

The url after # will loss,the server can't get it!!

## Reproduction Steps

```python
import requests
import time

![loss](https://user-images.githubusercontent.com/46711557/92478607-f8766d80-f214-11ea-9887-87ac05ad8f32.png)


url = 'https://ifm.zhaobenshu.com/User/user_ifa_LoginCard.ashx?a=[Lib={{gdut}}][OpenId={{}}][PmWebApiProxy={{}}][UrlQsLib={{#}}][Opac={{sulcmis4}}][OpacCaptcha={{0}}][UrlHost={{http://gdut.n1.zhaobenshu.com/}}][CardId={{' + \
req['account'] + '}}][CardPwd={{' + req['pwd'] + \
 '}}][UniSess={{}}][SessLib={{gdut}}][SessFun={{wap}}][SessPrd={{reso}}][CookiesStr={{}}][CaptchaStr={{}}]&x=&y=01&z=&_=' + \
        str(int(round(time.time() * 1000)))
res = requests.get(url)
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.3"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.22.0"
  },
  "system_ssl": {
    "version": "1010106f"
  },
  "urllib3": {
    "version": "1.25.8"
  },
  "using_pyopenssl": false
}
```


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.

> 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.

No,this is a bug,the url after '#' will loss.
For example,requests.get('http://www.xxxx#aaa.com') only  requests.get('http://www.xxx')

> No,this is a bug,the url after '#' will loss.
For example,requests.get('http://www.xxxx#aaa.com') only requests.get('http://www.xxx')

Hi @ch-boogeyman, this appears to be a fundamental misunderstanding of how URI fragments work. Everything after the hash is considered client-side and won't be transmitted to the server. You can find more information [here](https://tools.ietf.org/html/rfc3986#section-3.5). If you have more questions, please direct them to StackOverflow as requested. Thanks!
Other APIs are fetching normal, but some APIs takes time 2-5 minutes to get response, jquery Ajax fetches in milli seconds same APIs

I need to integrate ShipStation with my Python web app. ShipStation APIs are executing very slower, taking time about 2-5 minutes. I also tried to fetch more heavier APIs which are fetching normally. 

I tested Shipstation APIs using jQuery Ajax, Postman and it's taking time in milliseconds, or 1-2seconds. What's wrong with requests library. Samples: 

# python  example -- taking minutes 2-5
```

import requests

# request header
headers = { 'Authorization': '' }

# shipstaion carrier services listing api endpoint
list_services = 'https://ssapi.shipstation.com/carriers/listservices?carrierCode=stamps_com'

# making get request
res = requests.get(list_services, headers=headers)

# results
print("services_list: ", res, " and type is: ", type(res))
```


# jQuery Ajax example taking milliseconds or 1-2 seconds:


```
<html>
	<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
	</head> 
	<body>
	</body>
	<script>
		$.ajax({
		    url: 'https://ssapi.shipstation.com/carriers/listservices?carrierCode=stamps_com',
		    headers: { 'Authorization': '' },
		    type: "GET",
		    success: function(response)
                    {

                        console.log(response);//does not print in the console
                    }

		});
	</script>
</html>


```

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.
requests & async

Please refer to our [Stack Overflow tag](https://stackoverflow.com/questions/tagged/python-requests) for guidance.
Why my requests and async concurrent-use ，but without concurrent requests . 
my code format:
'''
async def requests_func():
    requests.post()
   
async def handle_func():
   await requests_func()
'''

please，please，please ,help me

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.
Apply the Apache-2.0 license correctly

This follows instructions from the Apache Foundation. It also ensures
that the license will be correctly detected by license scanning tools.

Note that adding a NOTICE file triggers Section 4.d of the license,
which is usually intended by users of the license.

The text that was in the LICENSE file before this change is intended
(by the authors of the license) to be used as a file header, and not as
a full license notice for a project, but it is commonly used this way,
so I would of course understand if this change is rejected.
Customize message error in Response.raise_for_status()

I had to write a client to interact with CouchDB using `requests`. When calling `response.raise_for_status()` the message shown is the usual HTTP error message (like 404: Not found), but in the response body I have a more detailed explanation of the error (something like: {"error": "Not found", "reason": "The document has been deleted"}). To print this error I had to override the method of the response with a custom function.
Since I believe this could be a common situation, it would be very helpful to have the possibility to print different error messages passing a parameter to the call to `raise_for_status`.

The project's under feature freeze and even if it weren't, this is why wrapping libraries should follow a pattern like:

```py
# mylib/exceptions.py
class MyLibError(Exception):
    pass

class MyLibHTTPError(MyLibError):
    pass

# mylib/client.py

try:
   response.raise_for_status()
except requests.exceptions.HTTPError as e:
  raise MyLibHTTPError(...)
```
[bug]requests isn't work  when meets too long url,what can i do? 

Summary.

## Expected Result

What you expected.

## Actual Result

What happened instead.
When i am crawling a web,I meet a long url.it returned me a wrong result.
So i used fiddler to check what happen,it showed the url not complete.
How can i resolve it?
![lose](https://user-images.githubusercontent.com/46711557/91306837-b6463880-e7df-11ea-8b4d-45143ebf76aa.png)
![code](https://user-images.githubusercontent.com/46711557/91306843-b8a89280-e7df-11ea-9649-e449d3a66e4f.png)

## Reproduction Steps

```python
import requests
import time

    url = 'https://ifm.zhaobenshu.com/User/user_ifa_LoginCard.ashx?a=[Lib={{gdut}}][OpenId={{}}][PmWebApiProxy={{}}][UrlQsLib={{#}}][Opac={{sulcmis4}}][OpacCaptcha={{0}}][UrlHost={{http://gdut.n1.zhaobenshu.com/}}][CardId={{' + \
        req['account'] + '}}][CardPwd={{' + req['pwd'] + \
        '}}][UniSess={{}}][SessLib={{gdut}}][SessFun={{wap}}][SessPrd={{reso}}][CookiesStr={{}}][CaptchaStr={{}}]&x=&y=01&z=&_=' + \
        str(int(round(time.time() * 1000)))
    res = requests.get(url)
```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.3"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.22.0"
  },
  "system_ssl": {
    "version": "1010106f"
  },
  "urllib3": {
    "version": "1.25.8"
  },
  "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).


My url has a '#',we should replace it to empty.
Update index.rst to mention support Python 3.5+

The [README](https://github.com/psf/requests/blob/master/README.md) and [FAQ](https://github.com/psf/requests/blob/master/docs/community/faq.rst) mentions that it supports Python 3.5+. But, the `docs/index.rst` still mentions that the support is only for Python 3.4–3.7 which is misleading and is not consistent with other docs.

This PR is for the update of misleading text about python support and make it consistent with README and FAQ.
Response time differences between different OS(e.g. Windows and Ubuntu)

Hi, I send simple request to a website and get a response with requests library. When I run this code on Ubuntu I get response at 3secs but if I run this on Windows I get response below 1 second. What is problem?

I try with same versions. (requests 2.22, 2.23, 2.24)

Test Code:
`
def responseTime():
    start_time = time.time()
    requests.get("https://github.com/")
    stop_time = time.time()
    print(stop_time - start_time)
`

In Windows:
    0.2963371276855469 secs

In Ubuntu:
    5.247551441192627 secs


This is a tough thing for us to figure out as we don't have access to your systems or know anything about how they're configured. I recommend using Wireshark to see where in the request process things are getting hung up.

Closing this as not an issue, in the future use StackOverflow for questions like this.
Accept-Encoding can't be removed  

I am using requests  2.21.0

headers={
            'Connection':None,
            'Accept-Encoding':None,
            'Accept':None,
            'User-Agent':None
        }

session = requests.Session()
session.keep_alive = False

session.post(url,headers=headers, data=postData,verify=False)

I tired to remove "Accept-Encoding" for post request header

however it still shows Accept-Encoding: identity  which is NOT the same as Accept/User-Agent

How do I remove Accept-Encoding in the header?

Thanks!

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.

Hi @Dao258, I'd check documentation for using [Prepared Requests](https://requests.readthedocs.io/en/master/user/advanced/#prepared-requests). If you have further questions, please route them to StackOverflow. Thanks!
Cert behavior regression (2.14.0)

## TLDR;

requests used to ignore the cert parameter when used, now it raises an error when the certificate files are missing


-------

I'm certainly late to the party, but we found a regression introduced in requests 2.14.0

From the changelog:
> When users provide invalid paths to certificate bundle files or directories Requests now raises IOError, rather than failing at the time of the HTTPS request with a fairly inscrutable certificate validation error

When used with **http://** URLs, the previous behavior was to ignore the certificate completely.

"Now" requests will always raise an error regardless of the protocol


## Reproduction Steps

```python
import requests

req = requests.get('http://perdu.com', cert=('nope.crt', 'nope.key'))
print(req)
```

Works fine on 2.13.0, and raise an IOError with requests 2.14.0 and up (since the certificates does not exist)

As fixing this might introduce more regressions, feel free to close it as invalid

Hi @romuald, thanks for reporting this. We made this change intentionally due to the unintuitive failure mode prior to 2.14.0. Given it's been in place for a few year and this is the first feedback we've received about it, I think we'll leave it in place.
Proper scope for session object

I'm using requests in the back-end of my web-app, to get sensor data from another REST API, at 1 Hz. I'm using _one_ session instance for my entire app, which is used in ~5 threads to perform the HTTP requests; typically around 5-10 per cycle. There's some error handling and all the fun stuff, to make sure the program just skips to the next cycle if one of the requests fails. In a nutshell, it looks something like this:

```python 
from concurrent.futures import ThreadPoolExecutor, as_completed
import requests 
import threading
import time

from requests_negotiate_sspi.requests_negotiate_sspi import HttpNegotiateAuth

class MyAPI: 
    
    def __init__(self, host):
        self._host = host
        self._session = Session()
        self._session.auth = HttpNegotiateAuth()
        
    def get_a_lot_of_stuff(end_points: list): 
        with ThreadPoolExecutor(max_workers=5) as executor: 
            futures = []
            for end_point in end_points:
                futures.append(executor.submit(self._get_a_bit_of_stuff, end_point)) 
            for future in as_completed(futures): 
                r = future.result()
                r.raise_for_status()

    def _get_a_bit_of_stuff(end_point: str): 
        return self._session.get(self._host + end_point)
    

def main(): 
    my_api = MyAPI("http://my.host.com")\
    end_points = ["/0", "/1", "/2", "/3", "/4"]
    while True: 
        try:
            my_api.get_a_lot_of_stuff(end_points)
        except: 
            print("Whatever, m8...")
        time.sleep(1)

```

Works fine, nothing out of the ordinary there (at least I think)...

However... I noticed that after running smoothly for several hours, at some point the number of timeout errors starts to increase exponentially - eventually stopping the whole thing altogether - until suddenly everything returns to normal. 

After some tinkering, I found out this behavior could be prevented by calling `self._session.close()` whenever an exception occurs. The program just continues as normal afterwards. 

My limited expertise leads me to believe there is some connection pool buffer that is overflowing, or something of the sorts. Am I thinking in the right direction? 

What would be the 'proper' way to deal with this? It's important for me to re-use my connections, since I'm making ~5-10 calls per second to the same host, and NTLM authentication also requires an additional 2 calls per connection.  



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.