Index: django/core/servers/basehttp.py
===================================================================
--- django/core/servers/basehttp.py	(revision 5319)
+++ django/core/servers/basehttp.py	(working copy)
@@ -9,7 +9,7 @@
 
 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
 from types import ListType, StringType
-import os, re, sys, time, urllib
+import os, re, email.utils, sys, urllib
 
 __version__ = "0.1"
 __all__ = ['WSGIServer','WSGIRequestHandler','demo_app']
@@ -370,7 +370,7 @@
                 self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
                 if 'Date' not in self.headers:
                     self._write(
-                        'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
+                        'Date: %s\r\n' % email.utils.formatdate()[:26] + "GMT"
                     )
                 if self.server_software and 'Server' not in self.headers:
                     self._write('Server: %s\r\n' % self.server_software)
Index: django/contrib/sessions/middleware.py
===================================================================
--- django/contrib/sessions/middleware.py	(revision 5319)
+++ django/contrib/sessions/middleware.py	(working copy)
@@ -2,7 +2,7 @@
 from django.contrib.sessions.models import Session
 from django.core.exceptions import SuspiciousOperation
 from django.utils.cache import patch_vary_headers
-import datetime
+import datetime, email.utils, time
 
 TEST_COOKIE_NAME = 'testcookie'
 TEST_COOKIE_VALUE = 'worked'
@@ -97,7 +97,12 @@
                     expires = None
                 else:
                     max_age = settings.SESSION_COOKIE_AGE
-                    expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT")
+                    rfcdate = email.utils.formatdate(time.time()
+                                                     + settings.SESSION_COOKIE_AGE)
+                    # Fixed length date must have '-' separation in the format DD-MMM-YYYY
+                    # for compliance with Netscape cookie standard
+                    expires = (rfcdate[:7] + "-" + rfcdate[8:11] 
+                               + "-" + rfcdate[12:26] + "GMT")
                 new_session = Session.objects.save(session_key, request.session._session,
                     datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE))
                 response.set_cookie(settings.SESSION_COOKIE_NAME, session_key,
Index: django/utils/cache.py
===================================================================
--- django/utils/cache.py	(revision 5319)
+++ django/utils/cache.py	(working copy)
@@ -17,7 +17,7 @@
 "Accept-language" header.
 """
 
-import datetime, md5, re
+import email.utils, md5, re, time
 from django.conf import settings
 from django.core.cache import cache
 
@@ -43,7 +43,7 @@
             return (t[0].lower().replace('-', '_'), True)
 
     def dictvalue(t):
-        if t[1] == True:
+        if t[1] is True:
             return t[0]
         else:
             return t[0] + '=' + str(t[1])
@@ -72,16 +72,15 @@
     """
     if cache_timeout is None:
         cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
-    now = datetime.datetime.utcnow()
+    if cache_timeout < 0:
+        cache_timeout = 0 # Can't have max-age negative
     if not response.has_header('ETag'):
         response['ETag'] = md5.new(response.content).hexdigest()
     if not response.has_header('Last-Modified'):
-        response['Last-Modified'] = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
+        response['Last-Modified'] = email.utils.formatdate()[:26] + "GMT"
     if not response.has_header('Expires'):
-        expires = now + datetime.timedelta(0, cache_timeout)
-        response['Expires'] = expires.strftime('%a, %d %b %Y %H:%M:%S GMT')
-    if cache_timeout < 0:
-        cache_timeout = 0 # Can't have max-age negative
+        response['Expires'] = email.utils.formatdate(time.time() 
+                                                    + cache_timeout)[:26] + "GMT"
     patch_cache_control(response, max_age=cache_timeout)
 
 def add_never_cache_headers(response):
Index: django/middleware/http.py
===================================================================
--- django/middleware/http.py	(revision 5319)
+++ django/middleware/http.py	(working copy)
@@ -1,4 +1,4 @@
-import datetime
+import email.utils
 
 class ConditionalGetMiddleware(object):
     """
@@ -11,8 +11,7 @@
     Also sets the Date and Content-Length response-headers.
     """
     def process_response(self, request, response):
-        now = datetime.datetime.utcnow()
-        response['Date'] = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
+        response['Date'] = email.utils.formatdate()[:26] + "GMT"
         if not response.has_header('Content-Length'):
             response['Content-Length'] = str(len(response.content))
 
