Skip to content

fixes 'no redirects' configuration on redirect policy#5790

Merged
kristapratico merged 5 commits intoAzure:masterfrom
kristapratico:issue5787
Jun 11, 2019
Merged

fixes 'no redirects' configuration on redirect policy#5790
kristapratico merged 5 commits intoAzure:masterfrom
kristapratico:issue5787

Conversation

@kristapratico
Copy link
Contributor

No description provided.

@adxsdk6
Copy link

adxsdk6 commented Jun 10, 2019

Can one of the admins verify this patch?

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move the check out of increment method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two reasons:

  1. 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.
  2. 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.

# 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permit_redirects=True is the default value, not right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@xiangyan99 xiangyan99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look

Copy link
Member

@xiangyan99 xiangyan99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline

@kristapratico kristapratico merged commit 55c8295 into Azure:master Jun 11, 2019
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
@kristapratico kristapratico deleted the issue5787 branch July 5, 2019 22:43
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 this pull request may close these issues.

4 participants