Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r--src/node_http_parser.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index b409d007307..eada685f2d6 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -69,12 +69,13 @@ using v8::Uint32;
using v8::Undefined;
using v8::Value;
-const uint32_t kOnHeaders = 0;
-const uint32_t kOnHeadersComplete = 1;
-const uint32_t kOnBody = 2;
-const uint32_t kOnMessageComplete = 3;
-const uint32_t kOnExecute = 4;
-const uint32_t kOnTimeout = 5;
+const uint32_t kOnMessageBegin = 0;
+const uint32_t kOnHeaders = 1;
+const uint32_t kOnHeadersComplete = 2;
+const uint32_t kOnBody = 3;
+const uint32_t kOnMessageComplete = 4;
+const uint32_t kOnExecute = 5;
+const uint32_t kOnTimeout = 6;
// Any more fields than this will be flushed into JS
const size_t kMaxHeaderFieldsCount = 32;
@@ -204,6 +205,19 @@ class Parser : public AsyncWrap, public StreamListener {
url_.Reset();
status_message_.Reset();
header_parsing_start_time_ = uv_hrtime();
+
+ Local<Value> cb = object()->Get(env()->context(), kOnMessageBegin)
+ .ToLocalChecked();
+ if (cb->IsFunction()) {
+ InternalCallbackScope callback_scope(
+ this, InternalCallbackScope::kSkipTaskQueues);
+
+ MaybeLocal<Value> r = cb.As<Function>()->Call(
+ env()->context(), object(), 0, nullptr);
+
+ if (r.IsEmpty()) callback_scope.MarkAsFailed();
+ }
+
return 0;
}
@@ -939,6 +953,8 @@ void InitializeHttpParser(Local<Object> target,
Integer::New(env->isolate(), HTTP_REQUEST));
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "RESPONSE"),
Integer::New(env->isolate(), HTTP_RESPONSE));
+ t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnMessageBegin"),
+ Integer::NewFromUnsigned(env->isolate(), kOnMessageBegin));
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnHeaders"),
Integer::NewFromUnsigned(env->isolate(), kOnHeaders));
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnHeadersComplete"),