Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use Buffer for message body

  • Loading branch information...
commit 6d4a99ce077b927d8ce64081248f74b71432c867 1 parent 4803a5a
@mscdex authored
Showing with 6 additions and 4 deletions.
  1. +3 −3 README.md
  2. +3 −1 lib/nntp.js
View
6 README.md
@@ -29,7 +29,7 @@ Examples
console.log('Article #' + n);
console.log('Article ID: ' + id);
console.log('Article headers: ' + inspect(headers));
- console.log('Article body: ' + inspect(body));
+ console.log('Article body: ' + inspect(body.toString()));
});
});
c.on('error', function(err) {
@@ -153,9 +153,9 @@ Methods
* **headers**([< _string_ >which, ]< _function_ >callback) - _(void)_ - Retrieves the headers of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 4 parameters: < _Error_ >err, < _integer_ >articleNum, < _string_ >msgID, < _object_ >headers. `headers` values are always arrays (of strings).
-* **body**([< _string_ >which, ]< _function_ >callback) - _(void)_ - Retrieves the body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 4 parameters: < _Error_ >err, < _integer_ >articleNum, < _string_ >msgID, < _string_ >body. `body` is a binary string.
+* **body**([< _string_ >which, ]< _function_ >callback) - _(void)_ - Retrieves the body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 4 parameters: < _Error_ >err, < _integer_ >articleNum, < _string_ >msgID, < _string_ >body. `body` is a _Buffer_.
-* **article**([< _string_ >which, ]< _function_ >callback) - _(void)_ - Retrieves the headers and body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 5 parameters: < _Error_ >err, < _integer_ >articleNum, < _string_ >msgID, < _object_ >headers, < _string_ >body. `headers` values containing an Array stores duplicate header values. `body` is a binary string.
+* **article**([< _string_ >which, ]< _function_ >callback) - _(void)_ - Retrieves the headers and body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 5 parameters: < _Error_ >err, < _integer_ >articleNum, < _string_ >msgID, < _object_ >headers, < _string_ >body. `headers` values are always arrays (of strings). `body` is a _Buffer_.
### Extended protocol commands -- these _may not_ be implemented or enabled on all servers
View
4 lib/nntp.js
@@ -440,6 +440,8 @@ NNTP.prototype.body = function(what, cb) {
m = RE_STAT.exec(self._buffer.trim());
}
+ body = new Buffer(body, 'binary');
+
// article number, message id, string body
cb(undefined, parseInt(m[1], 10), m[2], body);
});
@@ -504,7 +506,7 @@ NNTP.prototype.article = function(what, cb) {
}
}
- body = self._buffer.substring(idxDCRLF + 4);
+ body = new Buffer(self._buffer.substring(idxDCRLF + 4), 'binary');
m = RE_STAT.exec(info);
Please sign in to comment.
Something went wrong with that request. Please try again.