new THTTPResponse()
Structure for direct write HTTP response. Passed as parameter to application level scripting methods (see App.registerEndpoint ) also accessible in in entity level scripting methods while in rest mode.
Implements string writer.
Caller MUST call writeEnd once in the end and set response statusCode
To send file content as a response without loading file into memory the following code can be used:
// Replace this comments by JSDocs style comment
// param {THTTPRequest} req
// param {THTTPResponse} resp
function getPublicDocument(req, resp){
resp.statusCode = 200;
resp.writeHead('Content-Type: !STATICFILE\r\nContent-Type: text/plain'); // !STATICFILE is a special content type - will be removed from headers by server during sending
resp.writeEnd('c:\\myFilesWithPasswords.txt');
}
- Implements:
Members
statusCode: Number
response HTTP status code
Methods
writeHead(header)
add response header(s). Can be called several times for DIFFERENT header
Arguments:
-
header
(String)
 one header or #13#10 separated headers
writeBinaryBase64(base64Data)
Write base64 encoded data as a binary representation (will decode from base64 to binary before write to response)
Arguments:
-
base64Data
(String)
writeEnd()
Write to internal buffer and set buffer content as HTTP response.
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:
writeHead(header)
add response header(s). Can be called several times for DIFFERENT header
Arguments:
-
header
(String)
 one header or #13#10 separated headers
writeBinaryBase64(base64Data)
Write base64 encoded data as a binary representation (will decode from base64 to binary before write to response)
Arguments:
-
base64Data
(String)
writeEnd()
Write to internal buffer and set buffer content as HTTP response.
write(data, encodingopt)
Write to source.
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: