Name: js-handler/node_modules/restify/lib/formatters/binary.js
| 1: | // Copyright 2012 Mark Cavage, Inc. All rights reserved. |
| 2: | |
| 3: | |
| 4: | |
| 5: | ///--- Exports |
| 6: | |
| 7: | function formatBinary(req, res, body) { |
| 8: | if (body instanceof Error) |
| 9: | res.statusCode = body.statusCode || 500; |
| 10: | |
| 11: | if (!Buffer.isBuffer(body)) |
| 12: | body = new Buffer(body.toString()); |
| 13: | |
| 14: | res.setHeader('Content-Length', body.length); |
| 15: | return (body); |
| 16: | } |
| 17: | |
| 18: | module.exports = formatBinary; |
