send user-agent to directory service

This commit is contained in:
j 2014-08-09 23:05:36 +02:00
parent b5df7332b3
commit 59e9966430
3 changed files with 5 additions and 7 deletions

View file

@ -17,7 +17,10 @@ base = settings.server['directory_service']
def get(vk): def get(vk):
id = vk.to_ascii(encoding='base64') id = vk.to_ascii(encoding='base64')
url ='%s/%s' % (base, id) url ='%s/%s' % (base, id)
r = requests.get(url) headers = {
'User-Agent': settings.USER_AGENT
}
r = requests.get(url, headers=headers)
sig = r.headers.get('X-Ed25519-Signature') sig = r.headers.get('X-Ed25519-Signature')
data = r.content data = r.content
if sig and data: if sig and data:
@ -37,6 +40,7 @@ def put(sk, data):
sig = sk.sign(data, encoding='base64') sig = sk.sign(data, encoding='base64')
url ='%s/%s' % (base, id) url ='%s/%s' % (base, id)
headers = { headers = {
'User-Agent': settings.USER_AGENT,
'X-Ed25519-Signature': sig 'X-Ed25519-Signature': sig
} }
try: try:

View file

@ -303,7 +303,6 @@ class Item(db.Model):
cover = None cover = None
if 'cover' in self.meta and self.meta['cover']: if 'cover' in self.meta and self.meta['cover']:
cover = ox.cache.read_url(self.meta['cover']) cover = ox.cache.read_url(self.meta['cover'])
#covers[self.id] = requests.get(self.meta['cover']).content
if cover: if cover:
icons[key] = cover icons[key] = cover
self.info['coverRatio'] = get_ratio(cover) self.info['coverRatio'] = get_ratio(cover)

View file

@ -295,11 +295,6 @@ class Node(Thread):
} }
t1 = datetime.utcnow() t1 = datetime.utcnow()
logger.debug('download %s', url) logger.debug('download %s', url)
'''
r = requests.get(url, headers=headers)
if r.status_code == 200:
content = r.content
'''
self._opener.addheaders = zip(headers.keys(), headers.values()) self._opener.addheaders = zip(headers.keys(), headers.values())
r = self._opener.open(url, timeout=self.TIMEOUT*2) r = self._opener.open(url, timeout=self.TIMEOUT*2)
if r.getcode() == 200: if r.getcode() == 200: