-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add URL with fragment to ClientResponse #2925
Conversation
I had a trouble retrieving URL fragment from response URL. I am aware that request should be sent without URL fragment, but I don't think that URL from response should be modified. |
Codecov Report
@@ Coverage Diff @@
## master #2925 +/- ##
==========================================
+ Coverage 97.99% 97.99% +<.01%
==========================================
Files 40 40
Lines 7514 7520 +6
Branches 1318 1318
==========================================
+ Hits 7363 7369 +6
Misses 48 48
Partials 103 103
Continue to review full report at Codecov.
|
HTTP response has no URL (unless it is not 3xx redirection).
|
This is what i meant. I need to know full URL I am getting redirected to because this is how I get application token. Here is a little example: https://dry-meadow-80563.herokuapp.com/tokenask It redirects to |
@@ -191,8 +191,8 @@ def __init__(self, method, url, *, | |||
url2 = url.with_query(params) | |||
q.extend(url2.query) | |||
url = url.with_query(q) | |||
self.url = url.with_fragment(None) | |||
self.original_url = url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this code before my commit looks strange to me:
self.url = url.with_fragment(None)
self.original_url = url
Both url
and original_url
are not modified after (at least by the object itself), so they are always the same.
And then original_url
is passed as url
for ClientResponse.
So, wasn't it actually intended to keep URL fragment in response object?
Let's consider The public API is By this, we will keep the behavior of existing code and provide a way for getting original unmodified URLs. Opinions? |
This might be a solution. But can you please explain my previous comment on code and this commit? |
Looks like @fafhrd91 wanted to implement exactly your initial intention, later we broke the behavior again.
|
Should I just put real url in |
I think we need both Documentation and tests are mandatory. |
.. attribute:: real_url | ||
|
||
Unmodified URL of request (:class:`~yarl.URL`). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add .. versionadded:: 3.2
tag
.. attribute:: real_url | ||
|
||
Requested *url* with URL fragment unstripped, :class:`yarl.URL` instance. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionadded:: 3.2
Thanks! |
* Fixed ClientResponse URL fragment * Added news entry * ClientResponse real_url property + doc + test * Fixed flake8 and doc-spelling errors * Updated docs
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
What do these changes do?
ClientResponse and RequestInfo now have real_url property, which is request url without fragment part being stripped
Checklist
CONTRIBUTORS.txt
CHANGES
folder