Raibek/requests-github-issues huggingface dataset:
How to define HTTP version?

Please refer to our [Stack Overflow tag](https://stackoverflow.com/questions/tagged/python-requests) for guidance.
how can i define HTTP verison in requests? like this:
GET /index.html HTTP/2.0

requests doesn't support HTTP/2.0 (yet?!)

Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor. There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic, thanks to urllib3.
Reference : - https://2.python-requests.org/en/master/


+1 for functionality to specify the HTTP protocol version, e.g. 1.1, 2.0, etc.

Yeah, we won't do that because we aren't support 2.0 for the foreseeable future.
cookies.get behavior

Pardon me... I'm not proficient in python...  This library appears to be the de-facto reference for http clients in other programming languages as well..  
it seems like many http get clients return raw cookie values. and require raw cookie names... because...   that's what this library does

The subtitle for this project is "http for humans"....   
This human isn't interested in the transport-layer encoding..  I want the human value

With all that said...  why :

----

## Expected Result
I would expect `response.cookies.get()` to 
a) expect a decoded name as a parameter and 
b) return a decoded (human) value

## Actual Result
Encoded value returned
if name was encoded for http transport...   I must pass encoded name to get value

response headers:
```
Set-Cookie: dingus=foo%3Bbar; path=/
Set-Cookie: a%3Bb=foo%3Bbar; path=/
```

```python
[nav] In [1]: import requests                                                                                                     

[ins] In [2]: r = requests.get('http://localhost/cookietest')                                                                          

[ins] In [3]: r.cookies.get('dingus')                                                                                             
Out[3]: 'foo%3Bbar'

[ins] In [4]: r.cookies.get('a;b')                                                                                                

[ins] In [5]: r.cookies.get('a%3Bb')                                                                                              
Out[5]: 'foo%3Bbar'
```
Python requests NOT Throwing an Exception When Using Session with HTTPAdapter

Anyone know how I can better handle this situation?  I can't have the script freezing indefinitely.  I appreciate any help.

https://stackoverflow.com/questions/56482980/python-requests-not-throwing-an-exception-when-using-session-with-httpadapter

If you set the total property in the Retry object to `False`, an exception is thrown, and the script no longer runs indefinitely.  So why does it not terminate unless `total` is set to `False`?

This issue appears to be specific to your environment configuration since both the responders on Stackoverflow and I cannot reproduce the issue. I don't believe this is a defect in Requests with the information provided.
get_encoding_from_headers methods return value

Summary.
The problem with this method is that for certain languages the ISO-8859 does not work.
## Expected Result
I would like all HTTP header text to be returned for any language and not just english.
What you expected.
Certain languages such as french http header text does not work.
## Actual Result
Encoding error with non english
What happened instead.
encoding error
## Reproduction Steps

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).


I'm going to resolve this with the same reasoning Kenneth used on the PR. This is currently the best interpretation we have over the available RFCs and reference clients. You can always set `encoding` on the Response object yourself before trying to read its contents, and it should work as expected. That would be the advised path forward in cases where encoding isn't specified.
Remove an obsolete attribute from Session.__attrs__

The extra attribute in `Session.__attrs__` makes an unpickled session have one more attribute than the original.  Removing it makes the original and the unpickled be identical.

Great catch, @nedbat! That's only been lingering for 8 years . Would you mind rebasing if you get a moment?

Rebased, thanks!

Hmm, rebasing and force-pushing apparently also "dismisses stale review"?  That certainly wasn't my intent....!
chardet version error

Please refer to our [Stack Overflow tag](https://stackoverflow.com/questions/tagged/python-requests) for guidance.
![image](https://user-images.githubusercontent.com/11982084/58844605-fe5ec580-8645-11e9-9168-d19d7aae50f5.png)
Need help installing request offline mode python version 2.7.5


Installed chardet version 2.2.1
Response contains empty strings 


I am sending a request with URL and three query parameters with one parameter is getting its value on command line but it  is not populating the values for "vendorDetails dictionary.
import requests
import sys
from collections import OrderedDict 

url = "https://api.macaddress.io/v1"
mac= str(sys.argv[1])
print(mac)
qs=OrderedDict()
qs = {"apiKey":"xxxxxxxxxxx","output":"json","search":sys.argv[1]}

for key, value in qs.items(): 
    print(key, value) 

response= requests.get(url,params=qs)
print(response.url)

print(response.text)

I am getting the below response but all the values are empty after a query for the below mac address. So If I hard code the mac value in the query string it works but when I use it as a command line argument then it is returning the response without any value

$ python  web2.py 4:38:39:ff:ef:57
4:38:39:ff:ef:57
('output', 'json')
('search', '4:38:39:ff:ef:57')
('apiKey', 'xxxx')
https://api.macaddress.io/v1?output=json&search=4%3A38%3A39%3Aff%3Aef%3A57&apiKey=at_o45w16Yxa6RDxXNSV7lAZkY4DMax2
https://api.macaddress.io/v1?output=json&search=4%3A38%3A39%3Aff%3Aef%3A57&apiKey=xxxxxxxxx
{"vendorDetails":{"oui":"","isPrivate":false,"companyName":"","companyAddress":"","countryCode":""},"blockDetails":{"blockFound":false,"borderLeft":"","borderRight":"","blockSize":0,"assignmentBlockSize":"","dateCreated":"","dateUpdated":""},"macAddressDetails":{"searchTerm":"4:38:39:ff:ef:57","isValid":false,"virtualMachine":"Not detected","applications":[],"transmissionType":"multicast","administrationType":"LAA","wiresharkNotes":"No details","comment":""}}

I am 



Initially I thought that this didn't look like an issue related to requests. But I ran your code out of curiosity. I was unable to reproduce the problem. I received the correct response even when inputting the mac address via parameter.

This doesn't appear to be a defect with Requests. I'm going to resolve this for now since it's not reproducible with a general example and there isn't enough evidence to show this isn't caused by the server.
How to send a encrypted json string with requests

Hi,  I need to send a json string with post type, but in my project, i need to encrypt it before send. After encrypt, the string like "h5QkXuq8mY4n73YX4mv/Ug\u003d\u003d", I can not find a way to send data like this, I can do this with jmeter easily, just put the encrypted string in request body. How should I do with requests?

Looks like binary base64 encoded payload in unicode to me, u'\u003d' is b'=' 

This would be a better question on usage for StackOverflow. Resolving since it's not a defect in Requests. Thanks for the suggestion, VeNoMouS.
[models] Fix '_encode_params'/'_encode_files'

Look at https://github.com/kennethreitz/requests/blob/master/requests/models.py#L100 or
https://github.com/kennethreitz/requests/blob/master/requests/models.py#L131
```
for v in vs:
    if v is not None:
        ...
```
When the type of `vs` is `dict`, `v` will be the field key, but not field value, the body of the request will be puzzling.
It would be better to prevent it.

Signed-off-by: weiyang <weiyang.ones@gmail.com>

https://github.com/kennethreitz/requests/issues/5058

Why was this PR deleted? This was a good fix imo.

I'll reopen this if necessary. @martimlobao
Client certificates AND self-signed

I have read many posts about the issues separately, and the only ones that work are the ones setting the verification as "False".

Is it possible to use both verify and cert?

This raises error

    session.verify = 'server.pem'
    session.cert = ('public.pem', 'private.pem')
Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert certificate unknown')])")))

Whereas this works:

    session.verify = False
    session.cert = ('public.pem', 'private.pem')
And this works:

    session.verify = 'server.pem'
    #session.cert = ('public.pem', 'private.pem')
Having problem trying to use module repeteadly

Hi!
 I am trying to  use this module to connect to a server. The system has to make a request repeatedly (every few minutes). I made a sub thread that makes the request. The issue is that the requests sometimes work and sometimes throw an exception even though I'm using the same url and methods. 

The error I get is: Failed to establish a new connection [Errno -3] Temporary failure in name resolution. 

the part that doesn't work is this:
{'passkey':passkey}
r = requests.get( url, params=pyload, headers={'Connection':'close'})

I have investigated an I realized I was not closing the previous connections, however the error occurs still

I was trying and found that when there is no internet connection this is the error occuring. So maybe that was the problem


I see you found the issue! 🥇  However, this reminds me that for the use case you describe (connecting very often) I recommend that you look into using sessions.

Ok thanks, will look into it

El lun., 3 de jun. de 2019 12:54 p. m., Ruben Sanchez <
notifications@github.com> escribió:

> I see you found the issue! 🥇 However, this reminds me that for the use
> case you describe (connecting very often) I recommend that you look into
> using sessions.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/kennethreitz/requests/issues/5102?email_source=notifications&email_token=AJRIHPYR4DZ3PX6LGGERGMTPYVSGJA5CNFSM4HONZR7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW2LBII#issuecomment-498380961>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AJRIHP5Q537LRNHLFJVK6JTPYVSGJANCNFSM4HONZR7A>
> .
>
clarification of some items related to contributing 

It could help potential new contributors if the "How to Contribute" section included the content or a link to the "Good Bug Reports" section of the contributing.md and a link to some simple example tests in step 4 

Great idea! Is it possible for you to submit PR for this?

I can work on CONTRIBUTING.md file.

@Glyphack any update on the CONTRIBUTING.md file? I am wondering how I should get started

Hi, I did not receive any response on this so I did not start it. I don't know should I start a PR and work on it or no


We already have a guide on the documentation iirc.
allow creating a read-only session object

that will allow only read methods (GET, OPTIONS). It should block POST and PUT (=raise an error). It wold make it simple to enforce that the session users only read :) But maybe using a use with read-only permissions is better. So you can probably forget it. Adding it here only for reference if someone goes this same dead end way.

GET requests can certainly be used to change things on the server, so they're not really read-only. Besides, these things are usually implemented on the server, not on the client. If you really need it, create a subclass of the existing object.

Hi @stardust85, thanks for the suggestion! I don't believe this is something we'd introduce directly into Requests itself, but you're welcome to subclass Session to create your own module for doing this. I'm sure you'll find others who find it useful as well.
Why stopped Python 3.4 support?

I found that PR #5092 has stopped support for Python 3.4, but I couldn't find the reasons

Can someone tell me why?

Hi @jerrymakesjelly, we discontinued support for 3.4 due to it [reaching end of life](https://www.python.org/dev/peps/pep-0429/#release-schedule) and no longer receiving updates. Many of our upstream dependencies have dropped support including some of our testing infrastructure.

Thanks for checking in on this!

@nateprewitt Thank you!
Why are cookies private on PreparedRequests objects?

I was hoping to check the state of cookies that were present on a `PreparedRequest` object but found that the cookies member is private. Is there a specific reason for this?

Could you let us know the use case of checking the state of cookies with `PreparedRequest`?

@kobayashi I was actually just using pdb to verify which cookies were being sent for a handful of requests as part of a test I was writing. I think I was just expecting it to have been a public member like it is on the response, which is why I asked.

because they're just metadata. the cookies being sent are present in the headers.
windows proxy settings taken only partly

 do run python 2.7/3.7 on a windows 7 host.
This host is AD managed. As part of the group policy the internet settings are set to automatically proxy configuration with an wpad.dat file at the AD server.
The configuration works. cos IE and Chrome can reach external and internal hosts. Some of the internal are excluded from proxy via no proxy rules inside the dat file.

But on python with requests im not able to reach the internal addresses which are excluded via the proxy file rules. Python always tries to get the data from the proxy.

The only solution was an extra environmental variable NO_PROXY with the ips not to be reached via the proxy.

These excluded IPs are common IPs and not private ! (90.0.0.0/8) is part of the wpad.dat exclusion

## Expected Result
either no proxy or all proxy settings should taken into account.

## Actual Result
every requests traffic is placed on the proxy
urllib3 works as expected

## Reproduction Steps

```python
import requests
import urllib3
http1 = urllib3.PoolManager()
r1 = http.request('GET', 'http://90.0.11.253:43001/')
r1.status 

r2 = requests.get('http://90.0.11.253:43001/')
r2.status_code

r1==r2 must be true but isnt

```

## System Information

    $ python -m requests.help

```
C:\Users\iwetzel\AppData\Local\Programs\Python\Python37-32>python -m requests.help
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.1"
  },
  "platform": {
    "release": "7",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.21.0"
  },
  "system_ssl": {
    "version": "1010009f"
  },
  "urllib3": {
    "version": "1.24.3"
  },
  "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).
Upload file to wunderlist through API


 I am trying to upload a file to wunderlist through their API
According to their documentation:
https://developer.wunderlist.com/documentation/endpoints/upload

**I have succeeded in the first step which is to create the  upload as follows:**
(I am using python requests library)

headers = {'X-Access-Token': access_token, 'X-Client-ID': client_id, 'Content-Type': 'application/json'}
params = {'content_type':'application/json' , 'file_name': 'abc.txt','file_size':18}
params = json.dumps(params)
uploaded_r= requests.post('https://a.wunderlist.com/api/v1/uploads', headers=headers, data=params)

and got the response with the authorization of the first part of upload
'{"id":243803653,"user_id":84497133,"state":"new","type":"upload","expires_at":"2019-05-16T08:18:02.331Z","part":{"url":"https://upload.wunderlist.io/592d3140-59e0-0137-6b42-22000a5207ef-1557994382-276676?partNumber=1&uploadId=dzmW8CIfAN0v2dUWPNYcL9QOhaCRMpYDm4Wgho2zhxOz91Z946vWraJIYkdg4ivV8kpazt08X5ubU2ddaySy3ObrorqsbTNNg01rj3GqTOzzz39gTJc9AymGyxSu2vEW","date":"Thu, 16 May 2019 08:18:02 UTC +00:00","authorization":"AWS AKIAJEN6W4AO3LJODOAA:E1h8SD6kstwOX3ID2RHs6jyHvGY="}}'

**The problem is:**
 I am trying to use the authorization and date to upload the file but I keep getting (SignatureDoesNotMatch) error

upload_url = ast.literal_eval(uploaded_r.text)['part']['url']
auth = ast.literal_eval(uploaded_r.text)['part']['authorization']
x_date = ast.literal_eval(uploaded_r.text)['part']['date']
upload_id = ast.literal_eval(uploaded_r.text)['id']


**I have tried the following:**

headers = {'Content-Type': '','Authorization': auth,'x-amz-date':x_date}
final_upload= requests.post(upload_url, data =open('abc.txt','rb')  ,headers=headers)

headers = {'Content-Type': '','Authorization': auth,'x-amz-date':x_date}
files = {'file':open('abc.txt','rb').read()}
final_upload= requests.post(upload_url, files=files  ,headers=headers)

headers = {'Content-Type': 'application/octet-stream','Authorization': auth,'x-amz-date':x_date}
files = {'file':open('abc.txt','rb').read()}
final_upload= requests.post(upload_url, files =open('abc.txt','rb')  ,headers=headers)



**I have tried also the put command:**

headers = {'Content-Type': '','Authorization': auth,'x-amz-date':x_date}
files = {'file':open('abc.txt','rb').read()}
final_upload= requests.put(upload_url, data =open('abc.txt','rb')  ,headers=headers)

but I get empty response and the next step which is mark the upload as finished returns (bad request) error
v2.22.0

2.22.0 (2019-05-15)
-------------------

**Dependencies**

- Requests now supports urllib3 v1.25.2.
  (note: 1.25.0 and 1.25.1 are incompatible)

**Deprecations**

- Requests has officially stopped support for Python 3.4.

This should address #5065, #5067, #5085.

It looks like I've been locked out of partial control on the repository when it was pulled out the Requests org. Only @kenneth-reitz can merge at this point. Once this is merged I can cut a new release to PyPI.

@nateprewitt It is weird but members of the ORG have permissions to merge. If there is no other concern I will go ahead to merge it.

Thanks.
Request instalation using conda

Summary.

I couldn't install request using conda as you see in the following message
conda install -c conda-forge/label/cf201901 requests
Solving environment: failed

CondaHTTPError: HTTP 404 NOT FOUND for url <https://conda.anaconda.org/py27h453aca2_1/noarch/repodata.json>
Elapsed: 00:00.501324
CF-RAY: 4d7647510c20d121-TXL

The remote server could not find the noarch directory for the
requested channel with url: https://conda.anaconda.org/py27h453aca2_1

As of conda 4.3, a valid channel must contain a `noarch/repodata.json` and
associated `noarch/repodata.json.bz2` file, even if `noarch/repodata.json` is
empty. please request that the channel administrator create
`noarch/repodata.json` and associated `noarch/repodata.json.bz2` files.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state.
Further configuration help can be found at <https://conda.io/docs/config.html>.




## 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).


This appears to be an issue with Conda infrastructure or your networking setup. I'd suggest reaching out to them if you're still experiencing issues.
http://pipenv.org > https://github.com/pypa/pipenv

It looks like a few of the resources on https://docs.pipenv.org/en/latest/ are broken, like the gif under "A short animation of pipenv at work" and the installation instructions are a bit behind what's on the GitHub repo. Maybe we should link to the repo directly? 

First time contributing, feel free to reject this!

let's fix pipenv.org instead :)

the website can't be a one man operation! ;D

`pipenv.org` seems dead, so the link goes into Nirvana now. Can this be reopened?
The vast majority of issues in the database do not have labels

The majority of the issues in the database are missing labels. Especially notable is the sparseness of issues with the "Contributor Friendly" label. When a potential contributor clicks the link in the second step of the README, they see five old issues:

![issue2_pic1](https://user-images.githubusercontent.com/40577023/57654716-b6d6a380-7589-11e9-92b2-9072070d629a.PNG)

It would be quite helpful for contributors--especially new contributors--if more issues were given tags.

Thank you for the feedback. We allocate resources to issue triage when they're available.
Need to upgrade urllib3 to latest version 

We are using piprot in our security build. recently our build is getting failed because of the following risk given by piprot.

```
python-piprot  medium  urllib3            Module is one or more minor versions out of date  Upgrade to v1.25.2 (Current: v1.24.2)
```

could you please let us know whether there is version upgrade possible in any time soon

Thanks in advance 



duplicate of #5067 

Resolving as duplicate. Issue is fixed in #5092.
replace `get_encoding_from_headers` default with `None`

This issue a suggestion for handling partial elements of issues #1737 and #2086 (#1774 and others too).  I'm bringing this up in a separate ticket because it is a specific fix for multiple tickets and I am willing to write a PR for it in requests3 and requests2.  (i would have just gone and generated a PR, but I can't figure out what the actual master for requests3 actually is)

my proposal is to do the following (some of which have already been discussed as possibilities):

alter `get_encoding_from_headers()`
---
replace the default value of `get_encoding_from_headers` with `None` when "text" is in the content_type header.  currently this is "ISO-8859-1"

https://github.com/kennethreitz/requests/blob/c501ec986daa4961cd9dee370b5d45ff2e524b37/requests/utils.py#L492-L493

add `Response.detected_encoding` attribute
---
extend `build_response` and `Response` to additionally stash the header decoding in `response.detected_encoding`.  this will allow the detected value to remain on the response object if `response.encoding` is changed by the consumer.

add `Response.text_encoding` property
---
add a `text_encoding` property to `Response` , which offloads some of the logic now in `text`, and will return "ISO-8859-1" 

https://github.com/kennethreitz/requests/blob/c501ec986daa4961cd9dee370b5d45ff2e524b37/requests/models.py#L835-L858


alter `Response.text` to use the new `.text_encoding` attribute
---
update the `text` property to use the new `.text_encoding` attribute. this just ties together all the above.

Goals
---

The goal of these changes is to positively identify situations where no response encoding was declared by the server.  The backwards incompatibility is that `None` will now be returned when inspecting `response.encoding` when there is no encoding for the response - however the effective encoding used to generate `.text` will be available in `response.text_encoding` .   

This still maintains compliance with RFC 2616, because `.text` will still interpret the lack of a declared encoding as having the required default charset of `ISO-8859-1`.  This simply allows developers to know when `ISO-8859-1` is being used in a default or explicit manner.

This approach doesn't address all aspects of those issues or close those tickets, but it offers a solution to many of the needs and concerns with some minor changes.
Importing requests very slow (4 seconds) on Raspberry Pi

We found that importing **requests** on Raspberry Pi is very slow.
It takes 4 seconds.

Given that Kodi calls python addons for every menu change, navigating within addons is dreadfully slow (at least 4 seconds in between clicks).

Profiling and system call tracing output at: https://github.com/Freso/script.module.requests/issues/25

Looking for a way to disable specific packages and keep requests more simple in nature.

## Expected Result
Sub-second behaviour as on Windows and Android.

## Actual Result
It appears that compiling the **rfc3986** regular expressions is taking up most of the meat here.

## Reproduction Steps

```python
#!/usr/bin/python

import sys

sys.path.append('/storage/.kodi/addons/script.module.chardet/lib')
sys.path.append('/storage/.kodi/addons/script.module.urllib3/lib')
sys.path.append('/storage/.kodi/addons/script.module.certifi/lib')
sys.path.append('/storage/.kodi/addons/script.module.idna/lib')
sys.path.append('/storage/.kodi/addons/script.module.requests/lib')

import cProfile

pr = cProfile.Profile()
pr.enable()
import requests

requests.get('https://vrtnu-api.vrt.be/suggest?facets[transcodingStatus]=AVAILABLE').json()
pr.disable()
pr.dump_stats('/tmp/profiling_stats')
```

## System Information

    $ python -m requests.help

*This also takes 5 seconds ;-)*

```
kodi03:~ # python -m requests.help
{
  "chardet": {
    "version": "3.0.4"
  }, 
  "cryptography": {
    "version": ""
  }, 
  "idna": {
    "version": "2.8"
  }, 
  "implementation": {
    "name": "CPython", 
    "version": "2.7.15"
  }, 
  "platform": {
    "release": "4.19.23", 
    "system": "Linux"
  }, 
  "pyOpenSSL": {
    "openssl_version": "", 
    "version": null
  }, 
  "requests": {
    "version": "2.21.0"
  }, 
  "system_ssl": {
    "version": "1000211f"
  }, 
  "urllib3": {
    "version": "1.25.2"
  }, 
  "using_pyopenssl": false
}
```

As I said in https://github.com/Freso/script.module.requests/issues/25#issuecomment-489087339, this is almost certainly directly due to https://github.com/urllib3/urllib3/issues/1590 (@dagwieers even mentions `rfc3986` compiling regexes himself as well) and may thus not really be a `requests` issue, though there might be something requests could maybe do to mitigate slowness induced by 3rd party dependencies?

This should have been resolved through the outcomes of urllib3/urllib3#1590.
http://python-requests.org is down 

Summary.
http://python-requests.org/ redirects to https://docs.python-requests.org/ instead of http://docs.python-requests.org/. 
## Expected Result
docs to be available

## Actual Result

Secure Connection Failed

## Reproduction Steps

```
curl https://docs.python-requests.org/

```

## System Information


```
N/A
```



Thanks! This should now be fixed :)

Something is broken about this again: `http://docs.python-requests.org/en/master/objects.inv` 301s to `href="https://2.python-requests.org//en/master/objects.inv`, but `2.python-requests.org` is returning a TLS error.

```
http: error: SSLError: HTTPSConnectionPool(host='2.python-requests.org', port=443): Max retries exceeded with url: /en/master/objects.inv (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1056)'))) while doing GET request to URL: https://2.python-requests.org/en/master/objects.inv
```
fix: CRLF injection in urllib3 - bump its version

https://app.snyk.io/vuln/SNYK-PYTHON-URLLIB3-174323 (CVE-2019-11236) is CRLF injection a vulnerability in the urllib3 library.
This PR bumps its version.
This might not be directly related to requests, but would forbid projects using requests from using a fixed version of `urllib3`

See eg. discussions in kennethreitz/requests#5063, kennethreitz/requests#5065, kennethreitz/requests#5067

closing since this is already being discussed. sorry for the noise.
get url-encodes params twice

Using v2.21.0 with python3. I may be doing something wrong, but it looks like `requests.get` double-encodes parameters.

## Expected Result

```python
>>> params = {"package": "hello", "s": "bionic,bionic-updates", "a": "amd64", "text": "on"}
>>> response = requests.get("http://people.canonical.com/~ubuntu-archive/madison.cgi", params)
>>> response.request.url
'https://people.canonical.com/~ubuntu-archive/madison.cgi?package=hello&s=bionic%2Cbionic-updates&a=amd64&text=on'
```

Note the expected encoding for the comma: `%2C`.

## Actual Result

```python
>>> params = {"package": "hello", "s": "bionic,bionic-updates", "a": "amd64", "text": "on"}
>>> response = requests.get("http://people.canonical.com/~ubuntu-archive/madison.cgi", params)
>>> response.request.url
'https://people.canonical.com/~ubuntu-archive/madison.cgi?package=hello&s=bionic%252Cbionic-updates&a=amd64&text=on'
```

Note the _actual_ encoding for the comma: `%252C`. Looks like it's getting encoded twice.

## Reproduction Steps

```python
import requests
params = {"package": "hello", "s": "bionic,bionic-updates", "a": "amd64", "text": "on"}
response = requests.get("http://people.canonical.com/~ubuntu-archive/madison.cgi", params)
print(response.request.url)
```

## System Information

    $ python -m requests.help

```
$ python3 -m requests.help
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.7"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.7"
  },
  "platform": {
    "release": "4.15.0-47-generic",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.21.0"
  },
  "system_ssl": {
    "version": "1010007f"
  },
  "urllib3": {
    "version": "1.24.2"
  },
  "using_pyopenssl": false
}
```

Ah, this is interesting. I missed the HTTP->HTTPS redirect. Note that if I use HTTPS directly, it works as expected:

```python
>>> params = {"package": "hello", "s": "bionic,bionic-updates", "a": "amd64", "text": "on"}
>>> response = requests.get("https://people.canonical.com/~ubuntu-archive/madison.cgi", params)
>>> response.request.url
'https://people.canonical.com/~ubuntu-archive/madison.cgi?package=hello&s=bionic%2Cbionic-updates&a=amd64&text=on'
```

It seems the double encoding only happens when following a redirect.

Was this fixed? Any comment at all?

Sorry for my action. Closed unintentionally.

This seems to be a server-side problem:

```
$ curl -sI "http://people.canonical.com/~ubuntu-archive/madison.cgi?package=hello&s=bionic%2Cbionic-updates&a=amd64&text=on" | grep Location 
Location: https://people.canonical.com/~ubuntu-archive/madison.cgi?package=hello&s=bionic%252Cbionic-updates&a=amd64&text=on
```

And the server-side problem is now fixed.
Posting a zip file to HTTP server in C

How to upload a file to HTTP server with SIM7600I module? I have used the AT commands as shown in the datasheet which I have attached, but I am getting error for HTTPPOSTFILE command.

Can you suggest me any other method in C, Keil project?

[SIM7500_SIM7600_SIM7800 Series_HTTP_AT Command Manual_V1.00.pdf](https://github.com/kennethreitz/requests/files/3126980/SIM7500_SIM7600_SIM7800.Series_HTTP_AT.Command.Manual_V1.00.pdf)
Failed to establish a new connection: [Errno 11003] getaddrinfo failed

If you try to install a module through pip, it generates this error. What just did not try. I could install packages by downloading from official sites, but I can’t do it, so this method is needed, and it’s also much more convenient. There was an option to use --proxy=user:pass@host:port, but I do not know what to enter in user, pass, host and port. I use the development environment Sublime Text, version of python 3.7.3. Very urgently, I rummaged through a bunch of sites - I did not find anything. I would be extremely grateful to the decision.
![1](https://user-images.githubusercontent.com/50078144/56865779-79dfae00-69da-11e9-8bd3-ebb14c4480d8.jpg)
When using easy_install:
![1 1](https://user-images.githubusercontent.com/50078144/56866013-5e29d700-69dd-11e9-86e0-aa93501c805a.jpg)






    



    font{
        line-height: 1.6;
    }
    ul,ol{
        padding-left: 20px;
        list-style-position: inside;
    }


    
    I can install the numpy module through pip successful ,it not generate error. My environment:Python3.7.2;pip19.0.3;win10 professional Edition I don't have python2 in my operating system.
    
    
     
    
        
                    
            
                
                    
                            
                                
                            
                            
                                dahlinsky
                            
                    
                        
                            
                                    dahlinsky@qq.com
                            
                        
                
            
        
        
    
    
        签名由
        网易邮箱大师
        定制
    
 

    On 4/28/2019 22:25，Abysssssss<notifications@github.com> wrote： 


If you try to install a module through pip, it generates this error. That just did not try. I could install packages by downloading from official sites, but I can’t do it, so this method is needed, and it’s also much more convenient. There was an option to use --proxy=user:pass@host:port, but I do not know what to enter in user, pass, host and port. I use the development environment Sublime Text. Very urgently, I rummaged through a bunch of sites - I did not find anything. I would be extremely grateful to the decision.





—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.
Fix some issues to improve adherence to best practices

Hi @kenneth-reitz,

I've fixed some style issues in the codebase to improve adherence to general best practices. 🚀 

These issues were highlighted when I ran a DeepSource analysis on my fork of requests. I've added the DeepSource config file as well, which can be used to connect requests to DeepSource -- so this analysis runs on every pull-request, which will make it easier to maintain quality on contributions. DeepSource is used by some popular open-source projects, like [uber/ludwig](https://deepsource.io/gh/uber/ludwig/). The product is, and will forever remain, free for open-source.

To connect requests and run analysis on every PR, there are three simple steps:
1. **Merge this PR.** I've added a customised `.deepsource.toml` for requests.
2. **Sign up on DeepSource** and grant access to this repository [here](https://deepsource.io/signup/).
3. **Activate analysis** on requests [here](https://deepsource.io/gh/kennethreitz/requests/).

*Disclaimer: I'm a co-founder of DeepSource. We use requests for our code of course, and would love to give back!*

can you make these contributions to https://github.com/kennethreitz/requests3?

@kenneth-reitz Done! Please take a look at kennethreitz/requests3#15.

Thanks @sanketsaurav. We typically won't take stylistic or layout change PRs. It looks like Kenneth merged kennethreitz/requests3#15 though, so I'll resolve this in favor of that one.
Client certificate authentication: Support certificates as string input

Hi,

I am using requests for an HTTPS query with client certificate authentication. Requests currently only supports passing my key pair as a filename argument. I need to be able to pass my client auth key pair as a string

The python code is compiled and needs to be distributed to end users. I think passing the certificate as file name input in this use case is highly insecure.

Requests Version: 2.20.1

This would require implementation in urllib3 first before Requests could use it. The only work-around is using an `SSLContext` object yourself. Closing this for now.
Question: Digest choose hash algorithm (HTTPDigestAuth)

I try to authenticate a post request using Digest authentication. The server returns a list of two authentication challenges with the hash algorithms MD5 & SHA-256. 

To authenticate I use a HTTPDigestAuth object. It creates the digest using the second hash in the list (in this case SHA-256). 

My question: is there a way to force the library to use MD5? Due to reasons, I don't want to use SHA-256, even though it is part of the authentication challenge.



I used my own authentication method as a workaround. But still, I am wondering if there is a more straight forward way to prioritize which algorithm to choose.

Hi @damanuel, it's not entirely clear what the challenge you're receiving looks like. There isn't formal way to specify which algorithm is used, so your current workaround is probably the best approach for now.
[doc website] Add a nice search experience

👋 team,

TL;DR: Add same search experience as https://pipenv.readthedocs.io/en/latest/

I'm working at Algolia on the a project called [DocSearch](https://community.algolia.com/docsearch/) which goal is to enhance documentation websites with exhaustive, fast and relevant search. You might have seen DocSearch live already on websites like [pipenv](https://pipenv.readthedocs.io/en/latest/), [Bootstrap](https://getbootstrap.com/), [Brew](https://brew.sh/) or [jQuery](https://jquery.com/).

I have created [a preview of this PR](https://docsearch-requests.netlify.com/) and what DocSearch on the requests website could will look like here. Feel free to try it and let us know what you think. Please not the learn-as-you-type experience and the typo tolerance:

[![demo of DocSearch + requests](https://cl.ly/4241871af591/download/Screen%20Recording%202019-04-23%20at%2007.50%20AM.gif)](https://docsearch-requests.netlify.com/)

The way DocSearch works is by crawling your content, pushing the results into an Algolia index, and then requesting this index directly from the website front-end through JavaScript.

We'll take care of crawling your website and populating the Algolia index with the latest changes every 24h for you. You don't need to change anything to your deployment process. The only thing you need to add are the following CSS and JS snippets that will bind the dropdown to your searchbox.

We built DocSearch with the idea of giving back to the Open-Source community. This is why your [crawling configuration](https://github.com/algolia/docsearch-configs/blob/master/configs/python-requests.json) is available on GitHub if you want to change it. We also have our own [documentation](https://community.algolia.com/docsearch/documentation/) to help you tweak the dropdown to your needs. You'll also have access to *analytics on the most searched terms* or those with *no results*. All of this is of course *entirely free*.

Follow realpython/python-guide#932, pypa/pipenv#3703, kennethreitz/requests-html#292, kennethreitz/requests3#14, kennethreitz/responder#347

Let me know if you need anything, we can grant you access to some analytics @kenneth-reitz
Allow urllib3 1.25.x

1.25.x will include a fix for `CVE-2019-11236`

https://github.com/urllib3/urllib3/issues/1553#issuecomment-484213670

Just here to say that urllib3 1.25 will be released soon.

@kenneth-reitz It's out https://pypi.org/project/urllib3/1.25/

The CI failures here are unrelated btw 🙂 

our tests failing, waiting for this PR to be merged.

Hi @ofek, thanks for putting this together. Per our usual release practice, we’ll do all the versioning and release doc updates in one PR before release. We’re working on getting the test issue resolved and 1.25 tested, then will aim to get a release out.

@nateprewitt Thanks! So upgrading a dep in a one-off PR like https://github.com/kennethreitz/requests/pull/4889 is uncommon then?

@ofek, yes that PR would be considered abnormal and only accepted because it was pushed out by a member of the Requests team.

@nateprewitt Any progress?

FYI there will probably be a urllib3==1.25.1 release in the next day or so. 

@nateprewitt urllib3==1.25.1 has been released. I would recommend disallowing urllib3==1.25 in the `install_requires`. :)

@sethmlarson Done! Just in case this gets merged

Tests are failing due to the requirement `pytest<4.1,>=2.7,>=2.8.0,>=3.6,>=4.4.0` which will never work. I'm guessing that multiple dependencies have their own requirement on `pytest`.

Also, does `urllib3!=1.25` expand out to `urllib3!=1.25.0`? Should that be made explicit? I assume this is put in to install `urllib3` v1.25.1 or later

Hi @EpicWink, we already have both of those issue resolved on a separate branch (urllib31.25) but are blocked on a couple fixes in urllib3 1.25.2. We’ll work on getting a patch out when that’s pushed.

I’m going to resolve this in favor of the other issues to reduce noise on the mailing list. Thanks!

urllib3 1.24.3 has been released which fixes only the CRLF injection issue for 1.24.X users.
should be closed when  post a file

the [post-a-multipart-encoded-file](http://www.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file) demo show:
```python
>>> url = 'https://httpbin.org/post'
>>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}

>>> r = requests.post(url, files=files)
>>> r.text
{
  ...
  "files": {
    "file": "<censored...binary...data>"
  },
  ...
}
```

here open a file `report.xls`, and in [`requests.module.RequestEncodingMixin`](https://github.com/kennethreitz/requests/blob/9742da7f91f595796a412a8150aacc00191be039/requests/models.py#L158) it read the opened file:
```python
            if isinstance(fp, (str, bytes, bytearray)):
                fdata = fp
            elif hasattr(fp, 'read'):
               # todo **here**
                fdata = fp.read()
            elif fp is None:
                continue
            else:
                fdata = fp
```

so i'm not sure if it should be close
How can I use other protocol?

How can I use other protocol, such as gopher, dict, file....

Since requests is an HTTP library, I don't believe it would be possible to use it with gopher. You might have better luck with [Pituophis](https://github.com/dotcomboom/Pituophis)

> 
> 
> Since requests is an HTTP library, I don't believe it would be possible to use it with gopher. You might have better luck with [Pituophis](https://github.com/dotcomboom/Pituophis)

thanks, I'll try
some issues about  proxy

Dear Supporter

  I used a proxy when I request some website, I found that my ip agent is not in effect. In order to verify this ， I used a fake ip proxy such as http://123.123.123.123:123, but when I used this ip to 
request this url "https://mobile.yangkeduo.com/goods2.html?goods_id=473261", it seems not connect porxy first, but the response is returned  and it is the real content from this url.  I can't understand why ip doesn't take effect.  Because the ip is fake I thought it will raise a proxyError。

Could you tell me why？

Zhao

Hi Supporter
  I debugged this request when I add the proxy in requests.session().proxies,   in the adapters.py the method  "conn = self.get_connection(request.url, proxies)"  the proxies turn to None,  

Dear @wz343450860 

If you request an https url, you should configure an http**s** proxy, configuring an http (not https) proxy wouldn't affect an https request.

Can you please confirm that you've configured an https proxy and requested an https url  - or vice versa - configured an http proxy and requested an http url?

If you can confirm it, can you please paste an example code which demonstrate the issue, the requests library version and python version?

Thanks!
why isn't Requests included natively with python?

I was curious with all of the heavy usage of `Requests` module, why isn't it just included as a standard python module?  Why does the user have to install it?

What does python expect the user to use instead?

[urllib.request](https://docs.python.org/3/library/urllib.request.html#module-urllib.request) is in the stdlib. 

While you *can* use that instead of `requests`, many prefer `requests` interfaces to `urllib`.

Kenneth's original reasoning for this is "The stdlib is where things go to die". However, he did propose adding it to the stdlib [here](https://github.com/kennethreitz/requests/issues/2424)




> [urllib.request](https://docs.python.org/3/library/urllib.request.html#module-urllib.request) is in the stdlib.
> 
> While you _can_ use that instead of `requests`, many prefer `requests` interfaces to `urllib`.

> Kenneth's original reasoning for this is "The stdlib is where things go to die". However, he did propose adding it to the stdlib [here](https://github.com/kennethreitz/requests/issues/2424)

Ok.  I understand more completely now.  And it does make sense now.  I didn't realize there was so much politics in getting a module included in the `stdlib` and the potential loss of control over updates/features.
socks4 proxies break after use

Summary.

## Expected Result

Socks4 proxies work

## Actual Result

![image](https://user-images.githubusercontent.com/30770221/56176064-705c4c00-5fbf-11e9-91ac-06b2431ec4b0.png)

The ips through the proxy and public ip are the same

Also, this code:
```python
sess.proxies.update({"https": "socks9000://0.0.0.0"})
sess.get("https://icanhazip.com")
```
Usually throws an exception because socks9000 doesn't exist. But when this bug appears, this line no longer throws an exception.


## Reproduction Steps

The problem only appears when charles proxy is on so there's probably some interference there

```python
import requests
def test_proxy(proxy, throw_exc=False):
    sess = requests.session()
    proxy_dict = {"https": "socks4://{}".format(proxy)}
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0'
    }
    sess.proxies.update(proxy_dict)
    if config.get_config()["charles"]:
        sess.verify = "cert.pem"
    try:
        r = sess.get('https://icanhazip.com/', headers=headers, timeout=15)
        # read response.text to release worker back to pool
        return r.text.strip()
    except requests.exceptions.ConnectionError as ex:
        if throw_exc:
            raise ex
        return False
    except requests.exceptions.InvalidSchema:
        print("ERROR! INSTALL PYSOCKS <pip install pysocks>!")
        sys.exit(501)
    except ProxyError as pe:
        raise pe
    except Exception as ex:
        if throw_exc:
            raise ex
        return False
```

I'm not too sure what causes this either, but this code here eventually starts returning non-proxy ip address which is super weird and mysterious

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.6.1"
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.2"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "1010102f",
    "version": "19.0.0"
  },
  "requests": {
    "version": "2.21.0"
  },
  "system_ssl": {
    "version": "101000af"
  },
  "urllib3": {
    "version": "1.24.1"
  },
  "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).


Unfortunately we can't help debug your proxy, you'll have to try debugging this yourself or using Stackoverflow. Good luck.
requests geting status_code is error

use requests.get('https://test.xiubi.com').status_code report web status_code '200'.
use 'wget' and 'curl' report web status_code '302'.

why requests report error status_code?

The site has a redirect header and "requests" will redirect automatically by default. If you use curl, you need to use the -L flag, then you'll get a 200 status code.
E.g. curl -L https://test.xiubi.com

Can this be closed?