Mercurial > farol > farol
comparison farol/main.py @ 159:5df0bef667ea
Set the User-Agent for external requests
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Mon, 22 Dec 2014 15:26:48 +0100 |
parents | 0a5b5b5549cb |
children | 4d8218fbe686 |
comparison
equal
deleted
inserted
replaced
158:d66532e1909e | 159:5df0bef667ea |
---|---|
107 use_cases=[('Create a security advisory and publish as CVRF', 100), | 107 use_cases=[('Create a security advisory and publish as CVRF', 100), |
108 ('Edit a security advisory in CVRF format', 100)] | 108 ('Edit a security advisory in CVRF format', 100)] |
109 ) | 109 ) |
110 | 110 |
111 def download_url(url): | 111 def download_url(url): |
112 request = urllib2.Request(url) | |
113 request.add_header('User-Agent', | |
114 app.config.get('USER_AGENT', | |
115 'Farol %s / FarolLuz %s' % ( | |
116 __version__, farolluz.__version__))) | |
112 proxy_host = app.config.get('PROXY_HOST', '') | 117 proxy_host = app.config.get('PROXY_HOST', '') |
113 if proxy_host: | 118 if proxy_host: |
114 proxy = urllib2.ProxyHandler({'http': proxy_host, 'https': proxy_host}) | 119 proxy = urllib2.ProxyHandler({'http': proxy_host, 'https': proxy_host}) |
115 opener = urllib2.build_opener(proxy) | 120 opener = urllib2.build_opener(proxy) |
116 urllib2.install_opener(opener) | 121 urllib2.install_opener(opener) |