Encoding 0 length data, returns '' instead of null

This commit is contained in:
Ryan Dahl
2010-02-22 12:07:07 -08:00
parent b8dee2eb20
commit 46ebaa00ce
2 changed files with 4 additions and 2 deletions

View File

@@ -170,7 +170,7 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
HandleScope scope;
if (!len) return scope.Close(Null());
if (!len) return scope.Close(String::Empty());
if (encoding == BINARY) {
const unsigned char *cbuf = static_cast<const unsigned char*>(buf);

View File

@@ -200,7 +200,9 @@ void ChildProcess::on_read(evcom_reader *r, const void *buf, size_t len) {
enum encoding encoding = isSTDOUT ?
child->stdout_encoding_ : child->stderr_encoding_;
Local<Value> data = Encode(buf, len, encoding);
// TODO emit 'end' event instead of null.
Local<Value> data = len ? Encode(buf, len, encoding) : Local<Value>::New(Null());
child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data);
child->MaybeShutdown();
}