Members
statusCode
statusCode
Response HTTP status code
Methods
badRequest(reasonopt) → boolean
Write a HTTP 400 Bad Request response. Return false
Arguments:
-
[reason]
(string)
 If specified will be written to log as error
notFound(reason) → boolean
Write a HTTP 404 Not Found response. Return false
Arguments:
-
reason
(string)
 If specified will be written to log as error
notImplemented(reason) → boolean
Write a HTTP 501 'Not Implemented response. Return false
Arguments:
-
reason
(string)
 If specified will be written to log as error
validateETag()
Perform a ETag based HTTP response caching.
Must be called after writeEnd called and and statusCode is defined.
In case statusCode === 200 and response body length > 64 will
- if request contains a IF-NONE-MATCH header, and it value equal to response crc32
will mutate a statusCode to 304 (not modified) and clear the response body
- in other case will add a ETag header with value = hex representation of crc32(responseBody).
write(data, encodingopt)
Write to source.
Arguments:
-
data
(ArrayBuffer|Object|String)
 Data to write. If Object - it stringify before write
-
[encoding]
(String)
 Encode data to encoding
before write. Default to utf-8
in case data is String or bin
in case data is ArrayBuffer.
One of "utf-8"|"ucs2"|"bin"|"base64".
- Implements:
writeBinaryBase64(base64Data)
Write base64 encoded data as a binary representation (will decode from base64 to binary before write to response)
Arguments:
-
base64Data
(String)
writeEnd(data, encodingopt)
Write to internal buffer and set buffer content as HTTP response.
See {UBWriter.wrote} for parameter details
Arguments:
-
data
(ArrayBuffer|Object|String)
-
[encoding]
(String)
writeHead(header)
Add response header(s). Can be called several times for DIFFERENT header.
Can write several headers at once - in this case usa \r\n
as separator
Arguments:
-
header
(String)
 One header or \r\n
separated headers
Example
resp.writeHead('Content-Type: text/css; charset=UTF-8\r\nOther-header: value')
badRequest(reasonopt) → boolean
Arguments:
-
[reason]
(string)
 If specified will be written to log as error
notFound(reason) → boolean
Arguments:
-
reason
(string)
 If specified will be written to log as error
notImplemented(reason) → boolean
Arguments:
-
reason
(string)
 If specified will be written to log as error
validateETag()
Perform a ETag based HTTP response caching. Must be called after writeEnd called and and statusCode is defined.
In case statusCode === 200 and response body length > 64 will
- if request contains a IF-NONE-MATCH header, and it value equal to response crc32 will mutate a statusCode to 304 (not modified) and clear the response body
- in other case will add a ETag header with value = hex representation of crc32(responseBody).
write(data, encodingopt)
Arguments:
-
data
(ArrayBuffer|Object|String)
 Data to write. If Object - it stringify before write -
[encoding]
(String)
 Encode data toencoding
before write. Default toutf-8
in case data is String orbin
in case data is ArrayBuffer. One of "utf-8"|"ucs2"|"bin"|"base64".
- Implements:
writeBinaryBase64(base64Data)
Arguments:
-
base64Data
(String)
writeEnd(data, encodingopt)
Arguments:
-
data
(ArrayBuffer|Object|String)
-
[encoding]
(String)
writeHead(header)
\r\n
as separator
Arguments:
-
header
(String)
 One header or\r\n
separated headers
Example
resp.writeHead('Content-Type: text/css; charset=UTF-8\r\nOther-header: value')