diff options
author | zhangyongsheng <zhangyongsheng@youzan.com> | 2020-11-10 22:22:35 +0800 |
---|---|---|
committer | zhangyongsheng <zhangyongsheng@youzan.com> | 2020-11-11 23:14:56 +0800 |
commit | c0ac692ba786f235f9a4938f52eede751a6a73c9 (patch) | |
tree | 9ed4e1e498f1ec0553ff385d7792a581dff20c12 /src/node_http2.cc | |
parent | 564fcb8f7844660bb732d1bf96f352f7cd40411c (diff) | |
download | node-new-c0ac692ba786f235f9a4938f52eede751a6a73c9.tar.gz |
http2: allow setting the local window size of a session
PR-URL: https://github.com/nodejs/node/pull/35978
Fixes: https://github.com/nodejs/node/issues/31084
Refs: https://github.com/nodejs/node/pull/26962
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r-- | src/node_http2.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index b8e462419e..776393de8f 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -2416,6 +2416,25 @@ void Http2Session::SetNextStreamID(const FunctionCallbackInfo<Value>& args) { Debug(session, "set next stream id to %d", id); } +// Set local window size (local endpoints's window size) to the given +// window_size for the stream denoted by 0. +// This function returns 0 if it succeeds, or one of a negative codes +void Http2Session::SetLocalWindowSize( + const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + Http2Session* session; + ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder()); + + int32_t window_size = args[0]->Int32Value(env->context()).ToChecked(); + + int result = nghttp2_session_set_local_window_size( + session->session(), NGHTTP2_FLAG_NONE, 0, window_size); + + args.GetReturnValue().Set(result); + + Debug(session, "set local window size to %d", window_size); +} + // A TypedArray instance is shared between C++ and JS land to contain the // SETTINGS (either remote or local). RefreshSettings updates the current // values established for each of the settings so those can be read in JS land. @@ -3088,6 +3107,8 @@ void Initialize(Local<Object> target, env->SetProtoMethod(session, "request", Http2Session::Request); env->SetProtoMethod(session, "setNextStreamID", Http2Session::SetNextStreamID); + env->SetProtoMethod(session, "setLocalWindowSize", + Http2Session::SetLocalWindowSize); env->SetProtoMethod(session, "updateChunksSent", Http2Session::UpdateChunksSent); env->SetProtoMethod(session, "refreshState", Http2Session::RefreshState); |