Commit c691c18e authored by Seblu's avatar Seblu
Browse files

Try to disable http caching

parent 6b7a29da
......@@ -39,5 +39,11 @@ CACHE_PACKAGES = "packages.cache"
# Annouced version (from autoconf)
VERSION = "@VERSION@"
# user agent using with http request
USER_AGENT = "archversion v%s" % VERSION
# Http request headers
# Advertise archversion version
# Try to disable caching
HTTP_HEADERS = {
"User-Agent": "archversion v%s" % VERSION,
"Pragma": "no-cache",
"Cache-Control": "no-cache, no-store, must-revalidate"
}
\ No newline at end of file
......@@ -20,7 +20,7 @@
'''Version Module'''
from archversion import USER_AGENT, CONFIG_PACKAGES, CACHE_PACKAGES
from archversion import HTTP_HEADERS, CONFIG_PACKAGES, CACHE_PACKAGES
from archversion.config import BaseConfigFile
from archversion.database import JsonDatabase
from archversion.error import InvalidConfigFile, VersionNotFound
......@@ -204,7 +204,7 @@ class VersionController(object):
try:
logging.debug("Requesting url: %s (try %d/%d)" % (url, n, ntry))
logging.debug("Timeout is %s" % timeout)
url_req = Request(url, headers={"User-Agent": USER_AGENT})
url_req = Request(url, headers=HTTP_HEADERS)
url_fd = urlopen(url_req, timeout=timeout)
logging.debug("Version regex: %s" % regex)
v = re.findall(regex, url_fd.read().decode("utf-8"))
......@@ -271,7 +271,7 @@ class VersionController(object):
for repo in repos:
url = "http://www.archlinux.org/packages/%s/%s/%s/json" % (
repo, arch, name)
url_req = Request(url, headers={"User-Agent": USER_AGENT})
url_req = Request(url, headers=HTTP_HEADERS)
logging.debug("Requesting url: %s" % url)
logging.debug("Timeout is %s" % timeout)
try:
......@@ -292,7 +292,7 @@ class VersionController(object):
# retrieve config timeout
timeout = float(value["timeout"]) if "timeout" in value else None
url = "http://aur.archlinux.org/rpc.php?type=info&arg=%s" % name
url_req = Request(url, headers={"User-Agent": USER_AGENT})
url_req = Request(url, headers=HTTP_HEADERS)
logging.debug("Requesting url: %s" % url)
logging.debug("Timeout is %s" % timeout)
url_fd = urlopen(url_req, timeout=timeout)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment