summaryrefslogtreecommitdiff
path: root/django/core/servers/basehttp.py
diff options
context:
space:
mode:
authorChristopher Long <indirecthit@gmail.com>2007-06-17 22:18:54 +0000
committerChristopher Long <indirecthit@gmail.com>2007-06-17 22:18:54 +0000
commitae22b6d403dcf25098c77f0dfcf59ae58b186461 (patch)
treec37fc631e99a7e4d909d6b6d236f495003731ea7 /django/core/servers/basehttp.py
parent0cf7bc439129c66df8d64601e885f83b256b4f25 (diff)
per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@5488 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/servers/basehttp.py')
-rw-r--r--django/core/servers/basehttp.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
index a16b8b675a..9e603b42d4 100644
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -208,15 +208,15 @@ def guess_scheme(environ):
else:
return 'http'
-_hoppish = {
+_hop_headers = {
'connection':1, 'keep-alive':1, 'proxy-authenticate':1,
'proxy-authorization':1, 'te':1, 'trailers':1, 'transfer-encoding':1,
'upgrade':1
-}.has_key
+}
def is_hop_by_hop(header_name):
"""Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
- return _hoppish(header_name.lower())
+ return header_name.lower() in _hop_headers
class ServerHandler(object):
"""Manage the invocation of a WSGI application"""
@@ -309,7 +309,7 @@ class ServerHandler(object):
"""
if not self.result_is_file() and not self.sendfile():
for data in self.result:
- self.write(data)
+ self.write(data, False)
self.finish_content()
self.close()
@@ -334,7 +334,7 @@ class ServerHandler(object):
Subclasses can extend this to add other defaults.
"""
- if not self.headers.has_key('Content-Length'):
+ if 'Content-Length' not in self.headers:
self.set_content_length()
def start_response(self, status, headers,exc_info=None):
@@ -368,16 +368,16 @@ class ServerHandler(object):
if self.origin_server:
if self.client_is_modern():
self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
- if not self.headers.has_key('Date'):
+ if 'Date' not in self.headers:
self._write(
'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
)
- if self.server_software and not self.headers.has_key('Server'):
+ if self.server_software and 'Server' not in self.headers:
self._write('Server: %s\r\n' % self.server_software)
else:
self._write('Status: %s\r\n' % self.status)
- def write(self, data):
+ def write(self, data, flush=True):
"""'write()' callable as specified by PEP 333"""
assert type(data) is StringType,"write() argument must be string"
@@ -394,7 +394,8 @@ class ServerHandler(object):
# XXX check Content-Length and truncate if too many bytes written?
self._write(data)
- self._flush()
+ if flush:
+ self._flush()
def sendfile(self):
"""Platform-specific file transmission
@@ -421,8 +422,6 @@ class ServerHandler(object):
if not self.headers_sent:
self.headers['Content-Length'] = "0"
self.send_headers()
- else:
- pass # XXX check if content-length was too short?
def close(self):
try: