yet simpler header logic, thanks Anthony and Niphlod
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.0.8 (2012-09-11 14:02:50) stable
|
Version 2.0.8 (2012-09-11 14:06:40) stable
|
||||||
|
|||||||
+3
-3
@@ -89,14 +89,14 @@ class HTTP(BaseException):
|
|||||||
status = str(status)
|
status = str(status)
|
||||||
if not regex_status.match(status):
|
if not regex_status.match(status):
|
||||||
status = '500 %s' % (defined_status[500])
|
status = '500 %s' % (defined_status[500])
|
||||||
if not 'Content-Type' in headers:
|
headers.setdefault('Content-Type','text/html; charset=UTF-8')
|
||||||
headers['Content-Type'] = 'text/html; charset=UTF-8'
|
|
||||||
body = self.body
|
body = self.body
|
||||||
if status[:1] == '4':
|
if status[:1] == '4':
|
||||||
if not body:
|
if not body:
|
||||||
body = status
|
body = status
|
||||||
if isinstance(body, str):
|
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 += '<!-- %s //-->' % ('x'*512) ### trick IE
|
body += '<!-- %s //-->' % ('x'*512) ### trick IE
|
||||||
headers['Content-Length'] = len(body)
|
headers['Content-Length'] = len(body)
|
||||||
rheaders = []
|
rheaders = []
|
||||||
|
|||||||
+1
-2
@@ -556,8 +556,7 @@ def wsgibase(environ, responder):
|
|||||||
response.js.replace('\n','')))
|
response.js.replace('\n','')))
|
||||||
|
|
||||||
for key,value in default_headers:
|
for key,value in default_headers:
|
||||||
if not key in rheaders:
|
rheaders.setdefault(key,value)
|
||||||
rheaders[key] = value
|
|
||||||
|
|
||||||
# ##################################################
|
# ##################################################
|
||||||
# store cookies in headers
|
# store cookies in headers
|
||||||
|
|||||||
Reference in New Issue
Block a user