Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can choose whether to perform automatic url encoding and decoding #6385

Closed
ssrsec opened this issue Mar 21, 2023 · 1 comment
Closed

Can choose whether to perform automatic url encoding and decoding #6385

ssrsec opened this issue Mar 21, 2023 · 1 comment

Comments

@ssrsec
Copy link

ssrsec commented Mar 21, 2023

When I request with get, the content in the url will be automatically encoded or decoded or some other processing will be performed
Here are two examples:
[Example 1]
My real need is to send ' http://examole.com/1.jsp ;? Id=1 ', but in this example, the'; 'in the url Will be automatically ignored

import requests
url = ' http://examole.com/1.jsp ;? id=1'
res = requests.get(url, proxies={'http': '127.0.0.1:8080', 'https': '127.0.0.1:8080'})

When I try to manually encode the url first, the actual request becomes' http://examole.com/1.jsp%3b%3fid%3d1 '

url = ' http://examole.com/%31%2e%6a%73%70%3b%3f%69%64%3d%31 '
res = requests.get(url, proxies={'http': '127.0.0.1:8080', 'https': '127.0.0.1:8080'})

[Example 2]
My real need is to send ' http://examole.com/1.jsp?id=1 |Tid=2 ', in this example,' | 'will be encoded as'% 7C'

import requests
url = ' http://examole.com/1.jsp?id=1 |tid=2'
res = requests.get(url, proxies={'http': '127.0.0.1:8080', 'https': '127.0.0.1:8080'})

When I try to manually encode the url first, the actual request becomes' http://examole.com/1.jsp%3fid%3d1%7ctid%3d2 '

url = ' http://examole.com/%31%2e%6a%73%70%3f%69%64%3d%31%7c%74%69%64%3d%32 '
res = requests.get(url, proxies={'http': '127.0.0.1:8080', 'https': '127.0.0.1:8080'})

I cannot modify the source code of requests because it will affect the functionality of other businesses. Therefore, I hope you can provide an optional parameter to determine whether to send the original URL request.

For example:

res = requests.get(url, no_encode=False,proxies={'http': '127.0.0.1:8080', 'https': '127.0.0.1:8080'})

When no_ The default value of encode is True, which has the same effect as the current version. If no_ Encode=False, then the original url is sent without any processing.

@nateprewitt
Copy link
Member

Hi @heikanet, this is already possible with the PrepareRequest workflow described in our docs.

https://docs.python-requests.org/en/latest/user/advanced/#prepared-requests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants