'Return an HTTP header with HTTP-Date values as a datetime.
Args:
name (str): Header name, case-insensitive (e.g., \'Date\')
Keyword Args:
required (bool): Set to ``True`` to raise
``HTTPBadRequest`` instead of returning gracefully when the
header is not found (default ``False``).
obs_date (bool): Support obs-date formats according to
RFC 7231, e.g.: "Sunday, 06-Nov-94 08:49:37 GMT"
(default ``False``).
Returns:
datetime: The value of the specified header if it exists,
or ``None`` if the header is not found and is not required.
Raises:
HTTPBadRequest: The header was not found in the request, but
it was required.
HttpInvalidHeader: The header contained a malformed/invalid value.'

def get_header_as_datetime(self, header, required=False, obs_date=False):

    try:
        http_date = self.get_header(header, required=required)
        return util.http_date_to_dt(http_date, obs_date=obs_date)
    except TypeError:
        return None
    except ValueError:
        msg = 'It    must    be    formatted    according    to    RFC    7231,    Section    7.1.1.1'
        raise errors.HTTPInvalidHeader(msg, header)
