|
|
@ -9,6 +9,7 @@ function debug (x) { |
|
|
|
|
|
|
|
var sys = require('sys'); |
|
|
|
var net = require('net'); |
|
|
|
var Utf8Stream = require('utf8_stream').Utf8Stream; |
|
|
|
var events = require('events'); |
|
|
|
var Buffer = require('buffer').Buffer; |
|
|
|
|
|
|
@ -91,6 +92,8 @@ var parsers = new FreeList('parsers', 1000, function () { |
|
|
|
var enc = parser.incoming._encoding; |
|
|
|
if (!enc) { |
|
|
|
parser.incoming.emit('data', b.slice(start, start+len)); |
|
|
|
} else if (this._decoder) { |
|
|
|
this._decoder.write(pool.slice(start, end)); |
|
|
|
} else { |
|
|
|
var string = b.toString(enc, start, start+len); |
|
|
|
parser.incoming.emit('data', string); |
|
|
@ -198,6 +201,15 @@ IncomingMessage.prototype.setBodyEncoding = function (enc) { |
|
|
|
IncomingMessage.prototype.setEncoding = function (enc) { |
|
|
|
// TODO check values, error out on bad, and deprecation message?
|
|
|
|
this._encoding = enc.toLowerCase(); |
|
|
|
if (this._encoding == 'utf-8' || this._encoding == 'utf8') { |
|
|
|
this._decoder = new Utf8Stream(); |
|
|
|
this._decoder.onString = function(str) { |
|
|
|
this.emit('data', str); |
|
|
|
}; |
|
|
|
} else if (this._decoder) { |
|
|
|
delete this._decoder; |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
IncomingMessage.prototype.pause = function () { |
|
|
|