Skip to content

Commit

Permalink
Fix: node > 0.1.98 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Jun 26, 2010
1 parent a12f8a9 commit 37e00ac
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/formidable/incoming_form.js
Expand Up @@ -5,7 +5,7 @@ var sys = require('sys')
, WriteStream = require('fs').WriteStream
, MultipartParser = require('./multipart_parser').MultipartParser
, QuerystringParser = require('./querystring_parser').QuerystringParser
, Utf8Decoder = require('utf8decoder').Utf8Decoder
, StringDecoder = require('string_decoder').StringDecoder
, EventEmitter = require('events').EventEmitter;

function IncomingForm() {
Expand Down Expand Up @@ -130,21 +130,10 @@ IncomingForm.prototype.handlePart = function(part) {

if (!part.filename) {
var value = ''
, decoder;

if (this.encoding.toLowerCase() == 'utf-8') {
decoder = new Utf8Decoder();
decoder.onString = function(str) {
value += str;
};
}
, decoder = new StringDecoder(this.encoding);

part.addListener('data', function(buffer) {
if (decoder) {
decoder.write(buffer);
} else {
value += buffer.toString(self.encoding);
}
value += decoder.write(buffer);
});

part.addListener('end', function() {
Expand Down

0 comments on commit 37e00ac

Please sign in to comment.