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

Httpx is not encoding "%" symbol while sending requests #3140

Closed
heysarthak opened this issue Mar 11, 2024 Discussed in #3094 · 1 comment · Fixed by #3187
Closed

Httpx is not encoding "%" symbol while sending requests #3140

heysarthak opened this issue Mar 11, 2024 Discussed in #3094 · 1 comment · Fixed by #3187

Comments

@heysarthak
Copy link

Discussed in #3094

Originally posted by heysarthak February 14, 2024
Hi team,

I am ussing httpx plugin, while sending httpx query "ngi%abc.com" .
ideally "%" symbol should be encoded as "%25" but it is still sending as the same "%".

can we please have a fix for this.

Tunglies added a commit to Tunglies/httpx that referenced this issue Mar 14, 2024
Tunglies added a commit to Tunglies/httpx that referenced this issue Mar 14, 2024
Tunglies added a commit to Tunglies/httpx that referenced this issue Mar 14, 2024
Tunglies added a commit to Tunglies/httpx that referenced this issue Mar 15, 2024
Add parsing symbol '%s' test

rewrite fn::_urlparse::is_safe
@deedy5
Copy link

deedy5 commented Apr 6, 2024

% character has a special meaning in URLs, representing the start of a percent-encoded character. To include a literal % character in a URL, it must be percent-encoded as %25.

You can manually encode the query parameters in Python using the urllib.parse module:

from urllib.parse import quote
import httpx

query_param = "ngi%abc.com"
encoded_query_param = quote(query_param)

url = f"https://example.com/search?q={encoded_query_param}"
resp = httpx.get(url)

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

Successfully merging a pull request may close this issue.

2 participants