import { Response } from "https://deno.land/x/deno_koa@v1.0.4/response.ts";
Constructors
Properties
Get/Set the ETag of a response. This will normalize the quotes if necessary.
this.response.etag = 'md5hashsum';
this.response.etag = '"md5hashsum"';
this.response.etag = 'W/"123456789"';
Get the Last-Modified date in Date form, if it exists. Set the Last-Modified date using a string or a Date.
this.response.lastModified = new Date();
this.response.lastModified = '2013-09-13';
Methods
Append additional header field
with value val
.
Examples:
this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
this.append('Warning', '199 Miscellaneous warning');
Set Content-Disposition to "attachment" to signal the client to prompt for download. Optionally specify the filename of the download and some options.
Return response header. If the header is not set, will return an empty string.
The Referrer
header field is special-cased, both Referrer
and
Referer
are interchangeable.
Examples:
this.get('Content-Type');
// => "text/plain"
this.get('content-type');
// => "text/plain"
this.get('Something');
// => ''
Returns true if the header identified by name is currently set in the outgoing headers. The header name matching is case-insensitive.
Examples:
this.has('Content-Type');
// => true
this.get('content-type');
// => true
Check whether the response is one of the listed types.
Pretty much the same as this.request.is()
.
Perform a 302 redirect to url
.
The string "back" is special-cased
to provide Referrer support, when Referrer
is not present alt
or "/" is used.
Examples:
this.redirect('back'); this.redirect('back', '/index.html'); this.redirect('/login'); this.redirect('http://google.com');
Set header field
to val
, or pass
an object of header fields.
Examples:
this.set('Foo', ['bar', 'baz']); this.set('Accept', 'application/json'); this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });