-
Notifications
You must be signed in to change notification settings - Fork 259
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
Allow endpoints to have query parts. #469
Conversation
src/oic/oauth2/util.py
Outdated
@@ -57,7 +57,10 @@ def get_or_post(uri, method, req, content_type=DEFAULT_POST_CONTENT_TYPE, | |||
if method in ["GET", "DELETE"]: | |||
_qp = req.to_urlencoded() | |||
if _qp: | |||
path = uri + '?' + _qp | |||
if '?' in uri: |
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.
I think it might be safer to use urlsplit
and then append to the query
part of the result and the use urlunsplit
.
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.
You can't append to the query part of a Splitresult but I've tried to something similar.
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.
Yes, that is true. This works, but it can be simplified even more.
If you move the urlunsplit
from the condition you can then keep the update part and in the else
branch simpli assign the _qs
to _query
.
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.
I get your point and I think I actually dealt with in the latest version of the PR.
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.
Actually not, I have commented on the appropriate line.
Is this ready to merge and deploy or are there additional changes needed? |
src/oic/oauth2/util.py
Outdated
path = urlunsplit((comp.scheme, comp.netloc, comp.path, | ||
_query, comp.fragment)) | ||
else: | ||
path = uri + '?' + _qp |
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.
We can use the urlsplit/urlunsplit combo for this line as well. Since you are redoing this, it is a good idea to keep them the same.
Copy req since what don't want the update to spread outside this method.
src/oic/oauth2/util.py
Outdated
if req.keys(): | ||
comp = urlsplit(uri) | ||
if comp.query: | ||
req = req.copy() |
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 make this a first statement in the function to make it clear and hopefully error prone :)
Codecov Report
@@ Coverage Diff @@
## master #469 +/- ##
=========================================
- Coverage 58.68% 58.2% -0.48%
=========================================
Files 61 61
Lines 11289 11225 -64
Branches 1977 1907 -70
=========================================
- Hits 6625 6534 -91
- Misses 4126 4147 +21
- Partials 538 544 +6
Continue to review full report at Codecov.
|
* Allow endpoints to have query parts.
CHANGELOG.md
.