def test_dt_to_http(self): self.assertEqual( falcon.dt_to_http(datetime(2013, 4, 4)), 'Thu, 04 Apr 2013 00:00:00 GMT') self.assertEqual( falcon.dt_to_http(datetime(2013, 4, 4, 10, 28, 54)), 'Thu, 04 Apr 2013 10:28:54 GMT')
def test_dt_to_http(self): assert ( falcon.dt_to_http(datetime(2013, 4, 4)) == 'Thu, 04 Apr 2013 00:00:00 GMT' ) assert ( falcon.dt_to_http(datetime(2013, 4, 4, 10, 28, 54)) == 'Thu, 04 Apr 2013 10:28:54 GMT' )
def serialize(self): return { 'id': self.image_id, 'image': self.uri, 'modified': falcon.dt_to_http(self.modified), 'size': self.size, }
def _append_attribute_headers(self, headers): # NOQA if self.etag is not None: headers.append(("ETag", self.etag)) if self.cache_control is not None: headers.append(("Cache-Control", ", ".join(self.cache_control))) if self.last_modified is not None: headers.append(("Last-Modified", falcon.dt_to_http(self.last_modified))) if self.retry_after is not None: headers.append(("Retry-After", str(self.retry_after))) if self.vary is not None: headers.append(("Vary", ", ".join(self.vary))) if self.location is not None: headers.append(("Location", self.location)) if self.content_location is not None: headers.append(("Content-Location", self.content_location)) content_range = self.content_range if content_range is not None: # PERF: Concatenation is faster than % string formatting as well # as ''.join() in this case. formatted_range = ( "bytes " + str(content_range[0]) + "-" + str(content_range[1]) + "/" + str(content_range[2]) ) headers.append(("Content-Range", formatted_range))
def httpnow(): """Returns the current UTC time as an RFC 1123 date. Returns: str: An HTTP date string, e.g., "Tue, 15 Nov 1994 12:45:26 GMT". """ return falcon.dt_to_http(datetime.utcnow())
def httpnow(): """Returns the current UTC time as an HTTP date Returns: An HTTP date string, e.g., "Tue, 15 Nov 1994 12:45:26 GMT". See also: http://goo.gl/R7So4 """ return falcon.dt_to_http(datetime.utcnow())
def expires(self): now = datetime.datetime.utcnow() duration = datetime.timedelta(seconds=self.duration_seconds) return falcon.dt_to_http(now + duration)
def test_dt_to_http(self): assert falcon.dt_to_http(datetime(2013, 4, 4)) == 'Thu, 04 Apr 2013 00:00:00 GMT' assert falcon.dt_to_http( datetime(2013, 4, 4, 10, 28, 54) ) == 'Thu, 04 Apr 2013 10:28:54 GMT'
def httpnow(): return falcon.dt_to_http(datetime.utcnow())