Skip to content

Commit 7823f61

Browse files
committed
Move 'last_modified' and 'if_modified_since' properties
1 parent 903726b commit 7823f61

File tree

1 file changed

+26
-31
lines changed

1 file changed

+26
-31
lines changed

aiohttp/web_reqrep.py

+26-31
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,6 @@ def content_length(self, _CONTENT_LENGTH=hdrs.CONTENT_LENGTH):
6969
else:
7070
return int(l)
7171

72-
@property
73-
def if_modified_since(self, _IF_MODIFIED_SINCE=hdrs.IF_MODIFIED_SINCE):
74-
"""The value of If-Modified-Since HTTP header, or None.
75-
76-
This header is represented as a `datetime` object.
77-
"""
78-
httpdate = self.headers.get(_IF_MODIFIED_SINCE)
79-
if httpdate is not None:
80-
timetuple = parsedate(httpdate)
81-
if timetuple is not None:
82-
return datetime.datetime(*timetuple[:6],
83-
tzinfo=datetime.timezone.utc)
84-
return None
85-
86-
@property
87-
def last_modified(self, _LAST_MODIFIED=hdrs.LAST_MODIFIED):
88-
"""The value of Last-Modified HTTP header, or None.
89-
90-
This header is represented as a `datetime` object.
91-
"""
92-
httpdate = self.headers.get(_LAST_MODIFIED)
93-
if httpdate is not None:
94-
timetuple = parsedate(httpdate)
95-
if timetuple is not None:
96-
return datetime.datetime(*timetuple[:6],
97-
tzinfo=datetime.timezone.utc)
98-
return None
99-
10072
FileField = collections.namedtuple('Field', 'name filename file content_type')
10173

10274

@@ -229,6 +201,20 @@ def headers(self):
229201
"""A case-insensitive multidict proxy with all headers."""
230202
return self._headers
231203

204+
@property
205+
def if_modified_since(self, _IF_MODIFIED_SINCE=hdrs.IF_MODIFIED_SINCE):
206+
"""The value of If-Modified-Since HTTP header, or None.
207+
208+
This header is represented as a `datetime` object.
209+
"""
210+
httpdate = self.headers.get(_IF_MODIFIED_SINCE)
211+
if httpdate is not None:
212+
timetuple = parsedate(httpdate)
213+
if timetuple is not None:
214+
return datetime.datetime(*timetuple[:6],
215+
tzinfo=datetime.timezone.utc)
216+
return None
217+
232218
@property
233219
def keep_alive(self):
234220
"""Is keepalive enabled by client?"""
@@ -545,9 +531,18 @@ def charset(self, value):
545531
self._generate_content_type_header()
546532

547533
@property
548-
def last_modified(self):
549-
# Just a placeholder for adding setter
550-
return super().last_modified
534+
def last_modified(self, _LAST_MODIFIED=hdrs.LAST_MODIFIED):
535+
"""The value of Last-Modified HTTP header, or None.
536+
537+
This header is represented as a `datetime` object.
538+
"""
539+
httpdate = self.headers.get(_LAST_MODIFIED)
540+
if httpdate is not None:
541+
timetuple = parsedate(httpdate)
542+
if timetuple is not None:
543+
return datetime.datetime(*timetuple[:6],
544+
tzinfo=datetime.timezone.utc)
545+
return None
551546

552547
@last_modified.setter
553548
def last_modified(self, value):

0 commit comments

Comments
 (0)