Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up
  • Loading branch information
OrKoN committed Mar 17, 2020
commit f162c42f453acedb8c6b211a51b0214ec91b59c7
11 changes: 5 additions & 6 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const { OutgoingMessage } = require('_http_outgoing');
const {
kOutHeaders,
kNeedDrain,
nowDate,
emitStatistics
} = require('internal/http');
const {
Expand Down Expand Up @@ -427,7 +426,7 @@ function connectionListenerInternal(server, socket) {
server.maxHeaderSize || 0,
server.insecureHTTPParser === undefined ?
isLenient() : server.insecureHTTPParser,
server.headersTimeout,
server.headersTimeout || 0,
);
parser.socket = socket;
socket.parser = parser;
Expand Down Expand Up @@ -481,8 +480,8 @@ function connectionListenerInternal(server, socket) {
parser[kOnExecute] =
onParserExecute.bind(undefined, server, socket, parser, state);

parser[kOnTimeout] =
onParserTimeout.bind(undefined, server, socket, parser, state);
parser[kOnTimeout] =
onParserTimeout.bind(undefined, server, socket);

socket._paused = false;
}
Expand Down Expand Up @@ -576,7 +575,7 @@ function onParserExecute(server, socket, parser, state, ret) {
onParserExecuteCommon(server, socket, parser, state, ret, undefined);
}

function onParserTimeout(server, socket, parser, state, ret) {
function onParserTimeout(server, socket) {
const serverTimeout = server.emit('timeout', socket);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time tracking is moved to c++ code


if (!serverTimeout)
Expand Down Expand Up @@ -846,4 +845,4 @@ module.exports = {
ServerResponse,
_connectionListener: connectionListener,
kServerResponse
};
};
11 changes: 7 additions & 4 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@ class Parser : public AsyncWrap, public StreamListener {
max_http_header_size = env->options()->max_http_header_size;
}

CHECK(args[4]->IsInt32());
headers_timeout = args[4].As<Number>()->Value();
if (args.Length() > 4) {
CHECK(args[4]->IsInt32());
headers_timeout = args[4].As<Number>()->Value();
}

llhttp_type_t type =
static_cast<llhttp_type_t>(args[0].As<Int32>()->Value());
Expand Down Expand Up @@ -803,7 +805,8 @@ class Parser : public AsyncWrap, public StreamListener {
}


void Init(llhttp_type_t type, uint64_t max_http_header_size, bool lenient, uint64_t headers_timeout) {
void Init(llhttp_type_t type, uint64_t max_http_header_size,
bool lenient, uint64_t headers_timeout) {
llhttp_init(&parser_, type, &settings);
llhttp_set_lenient(&parser_, lenient);
header_nread_ = 0;
Expand Down Expand Up @@ -857,7 +860,7 @@ class Parser : public AsyncWrap, public StreamListener {
bool pending_pause_ = false;
uint64_t header_nread_ = 0;
uint64_t max_http_header_size_;
uint64_t headers_timeout_;
uint64_t headers_timeout_;
uint64_t header_parsing_start_time_ = 0;

// These are helper functions for filling `http_parser_settings`, which turn
Expand Down