send user-agent to directory service
This commit is contained in:
parent
b5df7332b3
commit
59e9966430
3 changed files with 5 additions and 7 deletions
|
@ -17,7 +17,10 @@ base = settings.server['directory_service']
|
|||
def get(vk):
|
||||
id = vk.to_ascii(encoding='base64')
|
||||
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')
|
||||
data = r.content
|
||||
if sig and data:
|
||||
|
@ -37,6 +40,7 @@ def put(sk, data):
|
|||
sig = sk.sign(data, encoding='base64')
|
||||
url ='%s/%s' % (base, id)
|
||||
headers = {
|
||||
'User-Agent': settings.USER_AGENT,
|
||||
'X-Ed25519-Signature': sig
|
||||
}
|
||||
try:
|
||||
|
|
|
@ -303,7 +303,6 @@ class Item(db.Model):
|
|||
cover = None
|
||||
if 'cover' in self.meta and self.meta['cover']:
|
||||
cover = ox.cache.read_url(self.meta['cover'])
|
||||
#covers[self.id] = requests.get(self.meta['cover']).content
|
||||
if cover:
|
||||
icons[key] = cover
|
||||
self.info['coverRatio'] = get_ratio(cover)
|
||||
|
|
|
@ -295,11 +295,6 @@ class Node(Thread):
|
|||
}
|
||||
t1 = datetime.utcnow()
|
||||
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())
|
||||
r = self._opener.open(url, timeout=self.TIMEOUT*2)
|
||||
if r.getcode() == 200:
|
||||
|
|
Loading…
Reference in a new issue