« index

Coverage for /Users/yunong/workspace/node-restify/lib/formatters/binary.js : 94%

17 lines | 16 run | 1 missing | 0 partial | 3 blocks | 2 blocks run | 1 blocks missing

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

  // Copyright 2012 Mark Cavage, Inc.  All rights reserved.
  
  
  ///--- Exports
  
  function formatBinary(req, res, body) {
      if (body instanceof Error)
          res.statusCode = body.statusCode || 500;
  
      if (!Buffer.isBuffer(body))
          body = new Buffer(body.toString());
  
      res.setHeader('Content-Length', body.length);
      return (body);
  }
  
  module.exports = formatBinary;
« index | cover.io