diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-03-14 04:06:03 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-03-14 04:06:03 (GMT) |
commit | 04bc5b9e4864a91f4dbea74ce2d88f606aa578f3 (patch) | |
tree | 6ae7ec19a0909304f5766a2b206f39d455c0d0b6 /Lib/http/server.py | |
parent | 0647ef05ebe3802617978b9f92922e6e9d33eaac (diff) | |
download | cpython-04bc5b9e4864a91f4dbea74ce2d88f606aa578f3.zip cpython-04bc5b9e4864a91f4dbea74ce2d88f606aa578f3.tar.gz cpython-04bc5b9e4864a91f4dbea74ce2d88f606aa578f3.tar.bz2 |
Issue #747320: Use email.utils.formatdate() to avoid code duplication
in BaseHTTPRequestHandler
Initial patch by karlcow.
Diffstat (limited to 'Lib/http/server.py')
-rw-r--r-- | Lib/http/server.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index e1b71ab..5e91826 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -87,6 +87,7 @@ __all__ = [ "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler", ] +import email.utils import html import http.client import io @@ -566,12 +567,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): """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) - return s + return email.utils.formatdate(timestamp, usegmt=True) def log_date_time_string(self): """Return the current time formatted for logging.""" |