Skip to content

Commit

Permalink
used custom user-agent; fix for #125, #127
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Aug 31, 2015
1 parent 3e9e861 commit b53f399
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
try: # pragma: no cover (py2 only)
from ConfigParser import SafeConfigParser as ConfigParser
from HTMLParser import HTMLParser
from urllib2 import urlopen
import urllib2
iteritems = operator.methodcaller('iteritems')
except ImportError: # pragma: no cover (py3 only)
from configparser import ConfigParser
from html.parser import HTMLParser
from urllib.request import urlopen
import urllib.request as urllib2
iteritems = operator.methodcaller('items')

from pkg_resources import parse_version

nodeenv_version = '0.13.3'
nodeenv_version = '0.13.4'

join = os.path.join
abspath = os.path.abspath
Expand Down Expand Up @@ -503,6 +503,12 @@ def get_node_src_url_postfix(opt):
postfix_arch = arches[platform.machine()]
return '-{0}-{1}'.format(postfix_system, postfix_arch)


def urlopen(url):
headers = { 'User-Agent' : 'nodeenv v.' + nodeenv_version }
req = urllib2.Request(url, None, headers)
return urllib2.urlopen(req)

# ---------------------------------------------------------
# Virtual environment functions

Expand Down

3 comments on commit b53f399

@tracker1
Copy link

Choose a reason for hiding this comment

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

I'd suggest 'nodeenv/' + nodeenv_version + ' (https://github.com/ekalinin/nodeenv/)' which would match convension for user agent strings[1]. While the link below is for automated agents, the convention is typical for utilities and scripts to provide a generic name/version with a url for the utility in the parameters section.

[1] https://en.wikipedia.org/wiki/User_agent#Format_for_automated_agents_.28bots.29

@ekalinin
Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, you're right. Will fix it. Thanks.

@ekalinin
Copy link
Owner Author

Choose a reason for hiding this comment

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

Fixed in 0.13.5

Please sign in to comment.