mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
e31059145a
commit
54319bd38d
|
@ -541,13 +541,17 @@ def daemon_http_get(self) -> None:
|
||||||
if 'newswire_favicon.ico' in self.path:
|
if 'newswire_favicon.ico' in self.path:
|
||||||
get_favicon(self, calling_domain, self.server.base_dir,
|
get_favicon(self, calling_domain, self.server.base_dir,
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
'newswire_favicon.ico')
|
'newswire_favicon.ico',
|
||||||
|
self.server.iconsCache,
|
||||||
|
self.server.domain_full)
|
||||||
return
|
return
|
||||||
|
|
||||||
# favicon image
|
# favicon image
|
||||||
if 'favicon.ico' in self.path:
|
if 'favicon.ico' in self.path:
|
||||||
get_favicon(self, calling_domain, self.server.base_dir,
|
get_favicon(self, calling_domain, self.server.base_dir,
|
||||||
self.server.debug, 'favicon.ico')
|
self.server.debug, 'favicon.ico',
|
||||||
|
self.server.iconsCache,
|
||||||
|
self.server.domain_full)
|
||||||
return
|
return
|
||||||
|
|
||||||
# check authorization
|
# check authorization
|
||||||
|
@ -1308,11 +1312,16 @@ def daemon_http_get(self) -> None:
|
||||||
if self.server.domain_full in self.path:
|
if self.server.domain_full in self.path:
|
||||||
# favicon for this instance
|
# favicon for this instance
|
||||||
get_favicon(self, calling_domain, self.server.base_dir,
|
get_favicon(self, calling_domain, self.server.base_dir,
|
||||||
self.server.debug, 'favicon.ico')
|
self.server.debug, 'favicon.ico',
|
||||||
|
self.server.iconsCache,
|
||||||
|
self.server.domain_full)
|
||||||
return
|
return
|
||||||
show_cached_favicon(self, referer_domain, self.path,
|
show_cached_favicon(self, referer_domain, self.path,
|
||||||
self.server.base_dir,
|
self.server.base_dir,
|
||||||
getreq_start_time)
|
getreq_start_time,
|
||||||
|
self.server.favicons_cache,
|
||||||
|
self.server.fitness,
|
||||||
|
self.server.debug)
|
||||||
return
|
return
|
||||||
|
|
||||||
# get css
|
# get css
|
||||||
|
|
|
@ -23,7 +23,8 @@ from utils import binary_is_image
|
||||||
|
|
||||||
def get_favicon(self, calling_domain: str,
|
def get_favicon(self, calling_domain: str,
|
||||||
base_dir: str, debug: bool,
|
base_dir: str, debug: bool,
|
||||||
fav_filename: str) -> None:
|
fav_filename: str,
|
||||||
|
icons_cache: {}, domain_full: str) -> None:
|
||||||
"""Return the site favicon or default newswire favicon
|
"""Return the site favicon or default newswire favicon
|
||||||
"""
|
"""
|
||||||
fav_type = 'image/x-icon'
|
fav_type = 'image/x-icon'
|
||||||
|
@ -68,12 +69,12 @@ def get_favicon(self, calling_domain: str,
|
||||||
print('favicon icon has not changed: ' + calling_domain)
|
print('favicon icon has not changed: ' + calling_domain)
|
||||||
http_304(self)
|
http_304(self)
|
||||||
return
|
return
|
||||||
if self.server.iconsCache.get(fav_filename):
|
if icons_cache.get(fav_filename):
|
||||||
fav_binary = self.server.iconsCache[fav_filename]
|
fav_binary = icons_cache[fav_filename]
|
||||||
set_headers_etag(self, favicon_filename,
|
set_headers_etag(self, favicon_filename,
|
||||||
fav_type,
|
fav_type,
|
||||||
fav_binary, None,
|
fav_binary, None,
|
||||||
self.server.domain_full,
|
domain_full,
|
||||||
False, None)
|
False, None)
|
||||||
write2(self, fav_binary)
|
write2(self, fav_binary)
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -90,10 +91,10 @@ def get_favicon(self, calling_domain: str,
|
||||||
set_headers_etag(self, favicon_filename,
|
set_headers_etag(self, favicon_filename,
|
||||||
fav_type,
|
fav_type,
|
||||||
fav_binary, None,
|
fav_binary, None,
|
||||||
self.server.domain_full,
|
domain_full,
|
||||||
False, None)
|
False, None)
|
||||||
write2(self, fav_binary)
|
write2(self, fav_binary)
|
||||||
self.server.iconsCache[fav_filename] = fav_binary
|
icons_cache[fav_filename] = fav_binary
|
||||||
if debug:
|
if debug:
|
||||||
print('Sent favicon from file: ' + calling_domain)
|
print('Sent favicon from file: ' + calling_domain)
|
||||||
return
|
return
|
||||||
|
@ -103,14 +104,16 @@ def get_favicon(self, calling_domain: str,
|
||||||
|
|
||||||
|
|
||||||
def show_cached_favicon(self, referer_domain: str, path: str,
|
def show_cached_favicon(self, referer_domain: str, path: str,
|
||||||
base_dir: str, getreq_start_time) -> None:
|
base_dir: str, getreq_start_time,
|
||||||
|
favicons_cache: {},
|
||||||
|
fitness: {}, debug: bool) -> None:
|
||||||
"""Shows a favicon image obtained from the cache
|
"""Shows a favicon image obtained from the cache
|
||||||
"""
|
"""
|
||||||
fav_file = path.replace('/favicons/', '')
|
fav_file = path.replace('/favicons/', '')
|
||||||
fav_filename = base_dir + urllib.parse.unquote_plus(path)
|
fav_filename = base_dir + urllib.parse.unquote_plus(path)
|
||||||
print('showCachedFavicon: ' + fav_filename)
|
print('showCachedFavicon: ' + fav_filename)
|
||||||
if self.server.favicons_cache.get(fav_file):
|
if favicons_cache.get(fav_file):
|
||||||
media_binary = self.server.favicons_cache[fav_file]
|
media_binary = favicons_cache[fav_file]
|
||||||
mime_type = media_file_mime_type(fav_filename)
|
mime_type = media_file_mime_type(fav_filename)
|
||||||
set_headers_etag(self, fav_filename,
|
set_headers_etag(self, fav_filename,
|
||||||
mime_type,
|
mime_type,
|
||||||
|
@ -118,9 +121,8 @@ def show_cached_favicon(self, referer_domain: str, path: str,
|
||||||
referer_domain,
|
referer_domain,
|
||||||
False, None)
|
False, None)
|
||||||
write2(self, media_binary)
|
write2(self, media_binary)
|
||||||
fitness_performance(getreq_start_time, self.server.fitness,
|
fitness_performance(getreq_start_time, fitness,
|
||||||
'_GET', '_show_cached_favicon2',
|
'_GET', '_show_cached_favicon2', debug)
|
||||||
self.server.debug)
|
|
||||||
return
|
return
|
||||||
if not os.path.isfile(fav_filename):
|
if not os.path.isfile(fav_filename):
|
||||||
http_404(self, 44)
|
http_404(self, 44)
|
||||||
|
@ -144,10 +146,9 @@ def show_cached_favicon(self, referer_domain: str, path: str,
|
||||||
referer_domain,
|
referer_domain,
|
||||||
False, None)
|
False, None)
|
||||||
write2(self, media_binary)
|
write2(self, media_binary)
|
||||||
fitness_performance(getreq_start_time, self.server.fitness,
|
fitness_performance(getreq_start_time, fitness,
|
||||||
'_GET', '_show_cached_favicon',
|
'_GET', '_show_cached_favicon', debug)
|
||||||
self.server.debug)
|
favicons_cache[fav_file] = media_binary
|
||||||
self.server.favicons_cache[fav_file] = media_binary
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('WARN: favicon is not an image ' + fav_filename)
|
print('WARN: favicon is not an image ' + fav_filename)
|
||||||
|
|
Loading…
Reference in New Issue