-
-
Notifications
You must be signed in to change notification settings - Fork 829
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
Finesse URL properties #1285
Merged
Merged
Finesse URL properties #1285
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some additional notes: We could have rocked on with We might want to look at bringing some extra niceties onto the URL class at some point, so... # Access the parsed `httpx.QueryParams` data structure.
url.params
# And then, include 'params' in `copy_with`.
url = url.copy_with(params={'search': 123})
# Allow the full set of `copy_with` parameters to be used on `__init__`.
# We could handle this pretty minimally using `.copy_with` under the hood.
# We already support `URL(..., params=...)`, so together with the previous
# two items, this could subsume the existing behaviour.
url = httpx.URL(scheme=..., host=..., path=...)
# Neater query parameter manipulations...
url = url.copy_adding_params({'search': '123'})
url = url.copy_removing_params('search') |
tomchristie
added
enhancement
New feature or request
user-experience
Ensuring that users have a good experience using the library
labels
Sep 18, 2020
DavidBord
added a commit
to DavidBord/httpx
that referenced
this pull request
Jan 29, 2021
florimondmanca
pushed a commit
that referenced
this pull request
Feb 7, 2021
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
user-experience
Ensuring that users have a good experience using the library
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Working towards making sure the
httpx.URL()
is fully consistent aroundstr
/bytes
and url escaped/unescaped representation.Refs #1275
Here's where it gets us too...
The components of a URL are broken down like this:
Note that:
url.scheme
is normalized to always be lowercased.url.host
is normalized to always be lowercased, and is IDNA encoded. For instance:assert httpx.URL("http://中国.icom.museum").host == "xn--fiqs8s.icom.museum"
url.userinfo
is raw bytes, without URL escaping. Usually you'll want to work withurl.username
andurl.password
instead, which handle the URL escaping.url.raw_path
is raw bytes of both the path and query, without URL escaping.This portion is used as the target when constructing HTTP requests. Usually you'll
want to work with
url.path
instead.url.query
is raw bytes, without URL escaping. A URL query string portion can onlybe properly URL escaped when decoding the parameter names and values themselves.
This full set of attributes are also available for use with
url.copy_with(...)
which type checks its arguments.