Spoof HTTP request header with empty agent#2083
Merged
boegel merged 4 commits intoeasybuilders:developfrom Jan 16, 2017
Merged
Conversation
This is necessary to avoid 403 errors from websites that do not allow Python-urllib headers
Member
|
@vanzod tests failed because of GitHub trouble it seems, just retriggered them |
boegel
reviewed
Jan 13, 2017
| attempt_cnt = 0 | ||
|
|
||
| # use blank HTTP header | ||
| header={'User-Agent':''} |
Member
There was a problem hiding this comment.
Why not be fair and use easybuild as user agent?
Member
Author
There was a problem hiding this comment.
No actual reason other than waiting for your reaction.
Member
|
related: #2021 |
boegel
requested changes
Jan 14, 2017
| max_attempts = 3 | ||
| attempt_cnt = 0 | ||
|
|
||
| # use blank HTTP header |
|
|
||
| while not downloaded and attempt_cnt < max_attempts: | ||
| try: | ||
| url_req = urllib2.Request(url, headers=header) |
Member
There was a problem hiding this comment.
@vanzod lets move this out of the while loop, only need to be constructed once, right? Also, you can merge this line with the one you addd above:
url_req = urllib2.Request(url, headers={'User-Agent': 'EasyBuild'})
while ...| attempt_cnt = 0 | ||
|
|
||
| # use blank HTTP header | ||
| header={'User-Agent':'EasyBuild'} |
Member
There was a problem hiding this comment.
style nitpicking: space after : (and spaces around =, but irrelevant with comment below)
Member
|
it works for me: |
boegel
approved these changes
Jan 16, 2017
Member
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.
A quick workaround to avoid 403 errors from HTTP requests to websites that do not allow connections from Python-urllib. This problem affects the installation of Anaconda when the installation shell script is not already present locally and needs to be downloaded.