Skip to content

Commit

Permalink
Fix http module issue
Browse files Browse the repository at this point in the history
 - writeHead function bug fix
  • Loading branch information
communix committed Feb 13, 2023
1 parent bc38f08 commit 192154e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/http/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class HTTPParser {
}
}
} else {
var len = parseInt(this.incoming.headers['content-length'] || '0');
var len = parseInt(this.incoming.headers['Content-Length'] || '0');
if (this._buf.length >= len) {
this.body = this._buf;
this._buf = '';
Expand Down Expand Up @@ -255,7 +255,7 @@ class ClientRequest extends OutgoingMessage {
* Flush headers to buffer.
*/
flushHeaders() {
if (!this.headers.hasOwnProperty['content-length']) {
if (!this.headers.hasOwnProperty['Content-Length']) {
this.setHeader('transfer-encoding', 'chunked');
}
this._wbuf += `${this.options.method} ${this.path} HTTP/1.1\r\n`;
Expand Down Expand Up @@ -343,7 +343,7 @@ class ServerResponse extends OutgoingMessage {
this.statusCode = statusCode;
if (statusMessage) this.statusMessage = statusMessage;
if (headers) Object.assign(this.headers, headers);
if (!this.headers.hasOwnProperty['content-length']) { // chunked transfer mode
if (!this.headers.hasOwnProperty['Content-Length']) { // chunked transfer mode
this.headers['transfer-encoding'] = 'chunked';
}
var msg = `HTTP/1.1 ${this.statusCode} ${this.statusMessage}\r\n`;
Expand Down

0 comments on commit 192154e

Please sign in to comment.