MCPcopy Index your code
hub / github.com/restify/node-restify / flush

Function flush

lib/response.js:858–887  ·  view source on GitHub ↗

* Flush takes our constructed response object and sends it to the client * * @private * @function flush * @param {Response} res - response * @param {String|Buffer} body - response body * @returns {Response} response

(res, body)

Source from the content-addressed store, hash-verified

856 * @returns {Response} response
857 */
858function flush(res, body) {
859 assert.ok(
860 body === null ||
861 body === undefined ||
862 typeof body === 'string' ||
863 Buffer.isBuffer(body),
864 'body must be a string or a Buffer instance'
865 );
866
867 res._data = body;
868
869 // Flush headers
870 res.writeHead(res.statusCode);
871
872 // Send body if it was provided
873 if (res._data) {
874 res.write(res._data);
875 }
876
877 // Finish request
878 res.end();
879
880 // If log level is set to trace, log the entire response object
881 if (res.log.trace()) {
882 res.log.trace({ res: res }, 'response sent');
883 }
884
885 // Return the response object back out to the caller of __send
886 return res;
887}
888
889/**
890 * formatterError is used to handle any case where we were unable to

Callers 2

patchFunction · 0.85
formatterErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected