diff -r 66d0f6ef2a7f Lib/http/server.py --- a/Lib/http/server.py Thu Feb 28 18:03:16 2013 +0200 +++ b/Lib/http/server.py Fri Mar 08 14:32:27 2013 -0500 @@ -87,6 +87,7 @@ import html import email.message import email.parser +import email.utils import http.client import io import mimetypes @@ -101,6 +102,7 @@ import urllib.parse import copy import argparse +import warnings # Default error message template @@ -538,26 +540,29 @@ """Return the current date and time formatted for a message header.""" if timestamp is None: timestamp = time.time() - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp) - s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( - self.weekdayname[wd], - day, self.monthname[month], year, - hh, mm, ss) + s = email.utils.formatdate(timestamp, localtime=False, usegmt=True) return s def log_date_time_string(self): """Return the current time formatted for logging.""" - now = time.time() - year, month, day, hh, mm, ss, x, y, z = time.localtime(now) - s = "%02d/%3s/%04d %02d:%02d:%02d" % ( - day, self.monthname[month], year, hh, mm, ss) + s = time.strftime("%d/%b/%Y %H:%M:%S", time.localtime()) return s - weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + # weekdayname is deprecated. Not used in that code anymore + @property + def weekdayname(self): + """Deprecated weekdayname variable""" + warnings.warn("Use of weekdayname is deprecated", DeprecationWarning, stacklevel=2) + return ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] - monthname = [None, - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + # monthname is deprecated. Not used in that code anymore + @property + def monthname(self): + """Deprecated monthname variable""" + warnings.warn("Use of monthname is deprecated", DeprecationWarning, stacklevel=2) + return [None, + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] def address_string(self): """Return the client address."""