Add experimental_cork to res
This commit is contained in:
parent
0686ce8592
commit
83a9a1f6cd
@ -215,6 +215,20 @@ struct HttpResponseWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Takes function, returns this (EXPERIMENTAL) */
|
||||||
|
template <bool SSL>
|
||||||
|
static void res_cork(const FunctionCallbackInfo<Value> &args) {
|
||||||
|
auto *res = getHttpResponse<SSL>(args);
|
||||||
|
if (res) {
|
||||||
|
|
||||||
|
res->cork([cb = Local<Function>::Cast(args[0])]() {
|
||||||
|
cb->Call(isolate->GetCurrentContext()->Global(), 0, nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
|
args.GetReturnValue().Set(args.Holder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <bool SSL>
|
template <bool SSL>
|
||||||
static void initResTemplate() {
|
static void initResTemplate() {
|
||||||
Local<FunctionTemplate> resTemplateLocal = FunctionTemplate::New(isolate);
|
Local<FunctionTemplate> resTemplateLocal = FunctionTemplate::New(isolate);
|
||||||
@ -237,6 +251,7 @@ struct HttpResponseWrapper {
|
|||||||
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onAborted"), FunctionTemplate::New(isolate, res_onAborted<SSL>));
|
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onAborted"), FunctionTemplate::New(isolate, res_onAborted<SSL>));
|
||||||
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onData"), FunctionTemplate::New(isolate, res_onData<SSL>));
|
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onData"), FunctionTemplate::New(isolate, res_onData<SSL>));
|
||||||
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getRemoteAddress"), FunctionTemplate::New(isolate, res_getRemoteAddress<SSL>));
|
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getRemoteAddress"), FunctionTemplate::New(isolate, res_getRemoteAddress<SSL>));
|
||||||
|
resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "experimental_cork"), FunctionTemplate::New(isolate, res_cork<SSL>));
|
||||||
|
|
||||||
/* Create our template */
|
/* Create our template */
|
||||||
Local<Object> resObjectLocal = resTemplateLocal->GetFunction()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
Local<Object> resObjectLocal = resTemplateLocal->GetFunction()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c1ea38ae10f7c9e4acf80c590d455e8f779d53ab
|
Subproject commit 799fe89a9b3d0ecf132e310ab4132ef0bd8c03f6
|
Loading…
x
Reference in New Issue
Block a user