def response(code, body='', etag=None, last_modified=None, expires=None, **kw):
    if etag is not None:
        if not (etag[0] == '"' and etag[-1] == '"'):
            etag = '"%s"' % etag
        kw['etag'] = etag
    if last_modified is not None:
        kw['last_modified'] = datetime_to_httpdate(last_modified)
    if expires is not None:
        if isinstance(expires, datetime):
            kw['expires'] = datetime_to_httpdate(expires)
        else:
            kw['expires'] = timedelta_to_httpdate(expires)
    headers = [(k.replace('_', '-').title(), v) for k, v in sorted(kw.items())]
    return Response(code, headers, body)