From 8f7bafb963b550949ad367d247a2a797afc2ef99 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 11 Sep 2012 14:06:44 -0500 Subject: [PATCH] yet simpler header logic, thanks Anthony and Niphlod --- VERSION | 2 +- gluon/http.py | 6 +++--- gluon/main.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 228b57df..3a3bb142 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.8 (2012-09-11 14:02:50) stable +Version 2.0.8 (2012-09-11 14:06:40) stable diff --git a/gluon/http.py b/gluon/http.py index 9cae6ac7..b42ec628 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -89,14 +89,14 @@ class HTTP(BaseException): status = str(status) if not regex_status.match(status): status = '500 %s' % (defined_status[500]) - if not 'Content-Type' in headers: - headers['Content-Type'] = 'text/html; charset=UTF-8' + headers.setdefault('Content-Type','text/html; charset=UTF-8') body = self.body if status[:1] == '4': if not body: body = status if isinstance(body, str): - if len(body)<512 and headers['Content-Type'].startswith('text/html'): + if len(body)<512 and \ + headers['Content-Type'].startswith('text/html'): body += '' % ('x'*512) ### trick IE headers['Content-Length'] = len(body) rheaders = [] diff --git a/gluon/main.py b/gluon/main.py index c0ef850e..1e9d02ae 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -556,8 +556,7 @@ def wsgibase(environ, responder): response.js.replace('\n',''))) for key,value in default_headers: - if not key in rheaders: - rheaders[key] = value + rheaders.setdefault(key,value) # ################################################## # store cookies in headers