FaaSHTTPResponse
Hierarchy
- ContextDelegatedResponse
- Pick<Writable, write | end>
- FaaSHTTPResponse
Index
Properties
body
etag
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"';
header
Return response header.
headers
Return response header, alias as response.header
lastModified
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';
length
Return parsed response Content-Length when present.
Set Content-Length field to n
.
status
Get/Set response status code.
streaming
Get/Set streaming response.
this.streaming = true;
type
Return the response mime type void of parameters such as “charset”.
Set Content-Type response header with type
through mime.lookup()
when it does not contain a charset.
Examples:
this.type = '.html';
this.type = 'html';
this.type = 'json';
this.type = 'application/json';
this.type = 'png';
Methods
append
Append additional header
field
with valueval
.Examples:
this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
this.append('Warning', '199 Miscellaneous warning');
get
Return response header. If the header is not set, will return an empty string.
The
Referrer
header field is special-cased, bothReferrer
andReferer
are interchangeable.Examples:
this.get('Content-Type');
// => "text/plain"
this.get('content-type');
// => "text/plain"
this.get('Something');
// => ''
is
Check whether the response is one of the listed types. Pretty much the same as
this.request.is()
.
redirect
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‘);
remove
Remove header
field
.
set
Set header
field
toval
, 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’ });
Get/Set response body.