diff --git a/CHANGES.txt b/CHANGES.txt index 58e2dae..80a7835 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +## Version 2.25.0 du 24/12/2015-11:15 + +6c73940 cgilsxml.py: désactiver le cache par défaut + ## Version 2.24.1 du 24/12/2015-10:12 3aba3e3 bug diff --git a/VERSION.txt b/VERSION.txt index 0f5dfbe..5c18f91 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -2.24.1 +2.25.0 diff --git a/lib/ulib/.ulibver b/lib/ulib/.ulibver index 6d1795a..e24b6c4 100644 --- a/lib/ulib/.ulibver +++ b/lib/ulib/.ulibver @@ -1 +1 @@ -009010000 +009011000 diff --git a/lib/ulib/support/cgilsxml.py b/lib/ulib/support/cgilsxml.py index 9362793..14ba866 100755 --- a/lib/ulib/support/cgilsxml.py +++ b/lib/ulib/support/cgilsxml.py @@ -173,6 +173,11 @@ def select_file(files, name): if matches: return matches[0] else: return None +def cgi_nocache(): + print "Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0" + print "Pragma: no-cache" + print "Expires: Thu, 01 Jan 1970 00:00:00 GMT" + def print_files(files, fgroups=None, select_group=None, script_name=None, query_string=None, xslt=None): xresult = ET.Element("result") xenv = ET.SubElement(xresult, "env") @@ -228,6 +233,8 @@ def run_cgilsxml(): + u"\n Il est possible de spécifier plusieurs champs pour le tri en les séparant par des virgules.") OP.add_option('--cgi', dest='cgi_mode', action='store_true', help=u"Activer le mode CGI. Ce mode est automatiquement activé si la variable d'environnement REQUEST_METHOD existe.") + OP.add_option('--cgi-allow-cache', dest='cgi_allow_cache', action='store_true', + help=u"En mode CGI, ne pas rajouter les en-tête désactivant la mise en cache du résultat.") OP.add_option('-P', '--cgi-path-info', dest='path_info', help=u"Spécifier un chemin d'un fichier à télécharger. En mode CGI, cette valeur est prise dans la variable d'environnement PATH_INFO") OP.add_option('-Q', '--cgi-query-string', dest='query_string', @@ -252,6 +259,7 @@ def run_cgilsxml(): sortby = o.sortby environ = os.environ + cgi_cache = o.cgi_allow_cache and True or False cgi_mode = o.cgi_mode if cgi_mode is None: cgi_mode = 'REQUEST_METHOD' in environ @@ -303,11 +311,13 @@ def run_cgilsxml(): file = select_file(files, cgi_path_info) if file is None: if cgi_mode: + if not cgi_cache: cgi_nocache() print "Content-Type: text/plain; charset=UTF-8" print print "Impossible de trouver le fichier %s" % cgi_path_info else: if cgi_mode: + if not cgi_cache: cgi_nocache() dlname = file.dlname or file.name ctype = file.has_key('type') and file.type or None if ctype is None: ctype, encoding = mimetypes.guess_type(dlname, False) @@ -321,6 +331,7 @@ def run_cgilsxml(): sys.exit() if cgi_mode: + if not cgi_cache: cgi_nocache() print "Content-Type: text/xml; charset=UTF-8" print print_files(files, fgroups, cgi_select_group, cgi_script_name, cgi_query_string, cgi_xslt)