Warn users that Requests doesn't support HTTP/2 (#361)

This commit is contained in:
Boris Verkhovskiy
2022-03-21 15:41:57 -07:00
committed by GitHub
parent 82fdaa0dba
commit a532bd4158
4 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1 @@
curl --http2 example.com

4
fixtures/python/get_http2_warning.py generated Normal file
View File

@@ -0,0 +1,4 @@
import requests
# Warning: this was an HTTP/2 request but requests only supports HTTP/1.1
response = requests.get('http://example.com')

View File

@@ -448,6 +448,12 @@ export const _toPython = request => {
} else if (filesString) {
pythonCode += filesString + '\n'
}
if (request.http2 || request.http3) {
// TODO: warn users out of band, not in the generated code
const version = request.http2 ? '2' : '3'
pythonCode += `# Warning: this was an HTTP/${version} request but requests only supports HTTP/1.1\n`
}
pythonCode += requestLine
if (jsonDataString && !jsonDataStringRoundtrips) {

View File

@@ -1159,6 +1159,13 @@ const buildRequest = parsedArguments => {
request.output = parsedArguments.output
}
if (parsedArguments.http2) {
request.http2 = parsedArguments.http2
}
if (parsedArguments.http3) {
request.http3 = parsedArguments.http3
}
return request
}