fixes 'no redirects' configuration on redirect policy#5790
Merged
kristapratico merged 5 commits intoAzure:masterfrom Jun 11, 2019
Merged
fixes 'no redirects' configuration on redirect policy#5790kristapratico merged 5 commits intoAzure:masterfrom
kristapratico merged 5 commits intoAzure:masterfrom
Conversation
|
Can one of the admins verify this patch? |
bryevdv
approved these changes
Jun 11, 2019
xiangyan99
reviewed
Jun 11, 2019
| for non_redirect_header in self._remove_headers_on_redirect: | ||
| response.http_request.headers.pop(non_redirect_header, None) | ||
| return settings['redirects'] > 0 or not settings['allow'] | ||
| return settings['redirects'] > 0 |
Member
There was a problem hiding this comment.
Why move the check out of increment method?
Contributor
Author
There was a problem hiding this comment.
Two reasons:
- The check for settings['allow'] is not getting executed here. When it is configured with no_redirects the 'redirects' in the settings still defaults to 30 attempts. So it will continue to make redirect attempts before evaluating if redirects are allowed.
- If 'allow' is checked in the increment method and is False, the method will return False which raises a TooManyRedirectsError in the send method instead of returning the response.
xiangyan99
reviewed
Jun 11, 2019
| # It can also be overridden per operation. | ||
| async with AsyncPipelineClient(base_url=url, config=config) as client: | ||
| response = await client._pipeline.run(request, redirect_max=5) | ||
| response = await client._pipeline.run(request, permit_redirects=True, redirect_max=5) |
Member
There was a problem hiding this comment.
permit_redirects=True is the default value, not right?
Contributor
Author
There was a problem hiding this comment.
Yes it is default value. The reason I used it here is because a couple lines up I disable redirects and then wanted to re-enable it for the test example. I'll move it to a separate test.
rajivnandivada
pushed a commit
to rajivnandivada/azure-sdk-for-python
that referenced
this pull request
Jul 3, 2019
* fixes no redirects configuration on redirect policy * adds a no redirects test
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.