lib/adapters/stomp.js
function encode(body) {
  // Handles 3 cases
  // - body is utf8 string
  // - body is instance of Buffer
  // - body is an object and its JSON representation is sent
  // Does not handle the case for streaming bodies.
  // Returns buffer.
  if (typeof(body) == 'string') {
    return [new Buffer(body, 'utf8')];
  } else if (body instanceof Buffer) {
    return [body];
  } else {
    var jsonBody = JSON.stringify(body);
    return [new Buffer(jsonBody, 'utf8'), 'application/json'];
  }
}
function encode(body) {
  // Handles 3 cases
  // - body is utf8 string
  // - body is instance of Buffer
  // - body is an object and its JSON representation is sent
  // Does not handle the case for streaming bodies.
  // Returns buffer.
  if (typeof(body) == 'string') {
    return [new Buffer(body, 'utf8')];
  } else if (body instanceof Buffer) {
    return [body];
  } else {
    var jsonBody = JSON.stringify(body);
    return [new Buffer(jsonBody, 'utf8'), 'application/json'];
  }
}
function encode ( body ) { // Handles 3 cases // - body is utf8 string // - body is instance of Buffer // - body is an object and its JSON representation is sent // Does not handle the case for streaming bodies. // Returns buffer. if ( typeof ( body ) == 'string' ) { return [ new Buffer ( body , 'utf8' ) ] ; } else if ( body instanceof Buffer ) { return [ body ] ; } else { var jsonBody = JSON . stringify ( body ) ; return [ new Buffer ( jsonBody , 'utf8' ) , 'application/json' ] ; } }
either encode msg as json, and return encoded msg and content-type value, or use string value and return null content-type @return [contentType, buffer] Note: implementation ripped out of node-amqp  XXX should this be merged to STOMP? if so, could be optional, triggered only if body is not a string/buffer, and if header has no content-type.
either encode msg as json and return encoded msg and content - type value or use string value and return null content - type