mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Send the install uuid when downloading builtin recipes from the new server for better recipe usage stats
This commit is contained in:
parent
f5bc132d2a
commit
cee98bbd0c
@ -154,7 +154,7 @@ else:
|
||||
getattr(ssl, 'match_hostname', match_hostname)(self.sock.getpeercert(), self.host)
|
||||
|
||||
def get_https_resource_securely(
|
||||
url, cacerts='calibre-ebook-root-CA.crt', timeout=60, max_redirects=5, ssl_version=None):
|
||||
url, cacerts='calibre-ebook-root-CA.crt', timeout=60, max_redirects=5, ssl_version=None, headers=None):
|
||||
'''
|
||||
Download the resource pointed to by url using https securely (verify server
|
||||
certificate). Ensures that redirects, if any, are also downloaded
|
||||
@ -195,7 +195,7 @@ def get_https_resource_securely(
|
||||
path = p.path or '/'
|
||||
if p.query:
|
||||
path += '?' + p.query
|
||||
c.request('GET', path)
|
||||
c.request('GET', path, headers=headers or {})
|
||||
response = c.getresponse()
|
||||
if response.status in (httplib.MOVED_PERMANENTLY, httplib.FOUND, httplib.SEE_OTHER):
|
||||
if max_redirects <= 0:
|
||||
|
@ -208,9 +208,11 @@ def download_builtin_recipe(urn):
|
||||
return get_https_resource_securely('https://status.calibre-ebook.com/recipe/'+urn)
|
||||
|
||||
def download_builtin_recipe2(urn):
|
||||
from calibre.utils.config_base import prefs
|
||||
from calibre.utils.https import get_https_resource_securely
|
||||
import bz2
|
||||
return bz2.decompress(get_https_resource_securely('https://code.calibre-ebook.com/recipe-compressed/'+urn))
|
||||
return bz2.decompress(get_https_resource_securely(
|
||||
'https://code.calibre-ebook.com/recipe-compressed/'+urn, headers={'CALIBRE-INSTALL-UUID':prefs['installation_uuid']}))
|
||||
|
||||
def get_builtin_recipe(urn):
|
||||
with zipfile.ZipFile(P('builtin_recipes.zip', allow_user_override=False), 'r') as zf:
|
||||
|
Loading…
x
Reference in New Issue
Block a user