Skip to content

Spoof HTTP request header with empty agent#2083

Merged
boegel merged 4 commits intoeasybuilders:developfrom
vanzod:http_spoof
Jan 16, 2017
Merged

Spoof HTTP request header with empty agent#2083
boegel merged 4 commits intoeasybuilders:developfrom
vanzod:http_spoof

Conversation

@vanzod
Copy link
Copy Markdown
Member

@vanzod vanzod commented Jan 13, 2017

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.

This is necessary to avoid 403 errors from websites that do not allow Python-urllib headers
@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 13, 2017

@vanzod tests failed because of GitHub trouble it seems, just retriggered them

@boegel boegel added this to the 3.1.0 milestone Jan 13, 2017
Comment thread easybuild/tools/filetools.py Outdated
attempt_cnt = 0

# use blank HTTP header
header={'User-Agent':''}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not be fair and use easybuild as user agent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No actual reason other than waiting for your reaction.

@pescobar
Copy link
Copy Markdown
Member

related: #2021

Comment thread easybuild/tools/filetools.py Outdated
max_attempts = 3
attempt_cnt = 0

# use blank HTTP header
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@vanzod this is not exactly blank anymore... :)

Comment thread easybuild/tools/filetools.py Outdated

while not downloaded and attempt_cnt < max_attempts:
try:
url_req = urllib2.Request(url, headers=header)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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 ...

Comment thread easybuild/tools/filetools.py Outdated
attempt_cnt = 0

# use blank HTTP header
header={'User-Agent':'EasyBuild'}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

style nitpicking: space after : (and spaces around =, but irrelevant with comment below)

@pescobar
Copy link
Copy Markdown
Member

it works for me:

[escobar@login18 ~]$ eb Anaconda2-4.0.0.eb
== temporary log file in case of crash /scratch/eb-IrfAkN/easybuild-AgIwYq.log
== processing EasyBuild easyconfig /scicore/home/scicore/escobar/.local/easybuild/software/EasyBuild/3.0.2/lib/python2.6/site-packages/easybuild_easyconfigs-3.0.2-py2.6.egg/easybuild/easyconfigs/a/Anaconda2/Anaconda2-4.0.0.eb
== building and installing Anaconda2/4.0.0...
== fetching files...
== creating build dir, resetting environment...
.
.
.

@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 16, 2017

Looks good, thanks for the fix @vanzod and @pescobar for verifying the fix!

@boegel boegel merged commit 7f1533b into easybuilders:develop Jan 16, 2017
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.

3 participants