mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #702 from berkerpeksag/use-email-utils-formatdate
Use email.utils.formatdate in gunicorn.util.http_date.
This commit is contained in:
commit
2ee1c26ec8
1
THANKS
1
THANKS
@ -71,3 +71,4 @@ keakon <keakon@gmail.com>
|
||||
Xie Shi <xieshi@douban.com>
|
||||
Steven Cummings <estebistec@gmail.com>
|
||||
Malthe Borch <mborch@gmail.com>
|
||||
Berker Peksag <berker.peksag@gmail.com>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
# See the NOTICE for more information.
|
||||
|
||||
|
||||
import email.utils
|
||||
import fcntl
|
||||
import io
|
||||
import os
|
||||
@ -34,11 +35,6 @@ CHUNK_SIZE = (16 * 1024)
|
||||
|
||||
MAX_BODY = 1024 * 132
|
||||
|
||||
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
monthname = [None,
|
||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
|
||||
# Server and Date aren't technically hop-by-hop
|
||||
# headers, but they are in the purview of the
|
||||
# origin server which the WSGI spec says we should
|
||||
@ -400,11 +396,7 @@ def http_date(timestamp=None):
|
||||
"""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" % (
|
||||
weekdayname[wd],
|
||||
day, monthname[month], year,
|
||||
hh, mm, ss)
|
||||
s = email.utils.formatdate(timestamp, localtime=False, usegmt=True)
|
||||
return s
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user