Skip to content

Commit

Permalink
remove log printings
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <[email protected]>
  • Loading branch information
shirady committed Feb 4, 2025
1 parent faa800f commit 385f83c
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/util/chunked_content_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ChunkedContentDecoder extends stream.Transform {

_flush(callback) {
if (this.state !== STATE_CONTENT_END) return this.error_state();
console.log('SDSD this.trailers', this.trailers);
return callback();
}

Expand Down Expand Up @@ -88,14 +87,9 @@ class ChunkedContentDecoder extends stream.Transform {
*/
/* eslint-disable max-statements */
parse(buf) {
console.log('SDSD JSON.stringify(buf.toString())', JSON.stringify(buf.toString()));
console.log('SDSD buf.length', buf.length);
for (let index = 0; index < buf.length; ++index) {
console.log('SDSD (outer loop) index', index);
if (this.state === STATE_READ_CHUNK_HEADER) {
console.log('SDSD this.state', this.state, 'index', index);
for (; index < buf.length; ++index) {
console.log('SDSD (inner loop) index', index);
if (buf[index] === CR_CODE) {
const header_items = this.chunk_header_str.split(';');
this.chunk_size = parseInt(header_items[0], 16);
Expand All @@ -105,7 +99,6 @@ class ChunkedContentDecoder extends stream.Transform {
const header1 = header_items[1].split('=');
this.chunk_signature = header1[0] === 'chunk-signature' ? header1[1] : '';
}
console.log('SDSD this.chunk_header_str', this.chunk_header_str);
this.chunk_header_str = '';
this.state = STATE_WAIT_NL_HEADER;
break;
Expand All @@ -114,19 +107,13 @@ class ChunkedContentDecoder extends stream.Transform {
}
}
} else if (this.state === STATE_WAIT_NL_HEADER) {
console.log('SDSD this.state', this.state, 'index', index);
if (buf[index] !== NL_CODE) return this.error_state();
this.state = STATE_SEND_DATA;
} else if (this.state === STATE_SEND_DATA) {
console.log('SDSD this.state', this.state, 'index', index);
const content = (index === 0 && buf.length <= this.chunk_size) ? buf : buf.subarray(index, index + this.chunk_size);
this.chunk_size -= content.length;
console.log('SDSD index before', index, this.state);
index += content.length - 1;
console.log('SDSD index after', index, this.state);
if (content.length) this.push(content);
console.log('SDSD this.chunk_size', this.chunk_size);
console.log('SDSD this.last_chunk', this.last_chunk);
if (!this.chunk_size) {
this.state = this.last_chunk ? STATE_READ_TRAILER_DATA : STATE_WAIT_CR_DATA;
}
Expand All @@ -138,49 +125,38 @@ class ChunkedContentDecoder extends stream.Transform {
index -= 1; // stay at current index
}
} else if (this.state === STATE_WAIT_CR_DATA) {
console.log('SDSD this.state', this.state, 'index', index);
if (buf[index] !== CR_CODE) return this.error_state();
this.state = STATE_WAIT_NL_DATA;
} else if (this.state === STATE_WAIT_NL_DATA) {
console.log('SDSD this.state', this.state, 'index', index);
if (buf[index] !== NL_CODE) return this.error_state();
console.log('SDSD this.last_chunk', this.last_chunk);
if (this.last_chunk) {
this.state = STATE_CONTENT_END;
} else {
this.state = STATE_READ_CHUNK_HEADER;
}
} else if (this.state === STATE_READ_TRAILER_DATA) {
console.log('SDSD this.state', this.state, 'index', index);
const start_trailer = index;
for (; index < buf.length; ++index) {
console.log('SDSD (new inner loop) index', index);
if (buf[index] === CR_CODE) {
this.state = STATE_WAIT_NL_TRAILER;
break;
}
this.chunk_trailer_str = buf.toString('utf8', start_trailer, index);
}
} else if (this.state === STATE_WAIT_NL_TRAILER) {
console.log('SDSD this.state', this.state, 'index', index);
if (buf[index] !== NL_CODE) return this.error_state();
this.trailers.push(this.chunk_trailer_str);
console.log('SDSD this.chunk_trailer_str', this.chunk_trailer_str);
this.state = STATE_CHECK_TRAILER;
} else if (this.state === STATE_WAIT_NL_END) {
console.log('SDSD this.state', this.state, 'index', index);
if (buf[index] !== NL_CODE) return this.error_state();
this.state = STATE_CONTENT_END;
} else {
console.log('SDSD in else condition this.state', this.state);
console.log('SDSD', 'index', index);
return this.error_state();
}
}
}

error_state() {
console.log('SDSD in error_state this.state', this.state);
this.state = STATE_ERROR;
this.emit('error', new Error('problem in parsing aws-chunked data'));
}
Expand Down

0 comments on commit 385f83c

Please sign in to comment.