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
http2: use const references for Http2Priority
Signed-off-by: James M Snell <jasnell@gmail.com>
  • Loading branch information
jasnell committed Apr 16, 2020
commit e8a2f5e2669e2d9f5deb924314a0eb0933dbe33d
20 changes: 9 additions & 11 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ int Http2Session::OnSendData(

// Creates a new Http2Stream and submits a new http2 request.
Http2Stream* Http2Session::SubmitRequest(
nghttp2_priority_spec* prispec,
const Http2Priority& priority,
const Http2Headers& headers,
int32_t* ret,
int options) {
Expand All @@ -1718,7 +1718,7 @@ Http2Stream* Http2Session::SubmitRequest(
Http2Stream::Provider::Stream prov(options);
*ret = nghttp2_submit_request(
session_.get(),
prispec,
&priority,
headers.data(),
headers.length(),
*prov,
Expand Down Expand Up @@ -2054,7 +2054,7 @@ int Http2Stream::SubmitTrailers(const Http2Headers& headers) {
}

// Submit a PRIORITY frame to the connected peer.
int Http2Stream::SubmitPriority(nghttp2_priority_spec* prispec,
int Http2Stream::SubmitPriority(const Http2Priority& priority,
bool silent) {
CHECK(!this->is_destroyed());
Http2Scope h2scope(this);
Expand All @@ -2063,11 +2063,11 @@ int Http2Stream::SubmitPriority(nghttp2_priority_spec* prispec,
nghttp2_session_change_stream_priority(
session_->session(),
id_,
prispec) :
&priority) :
nghttp2_submit_priority(
session_->session(),
NGHTTP2_FLAG_NONE,
id_, prispec);
id_, &priority);
CHECK_NE(ret, NGHTTP2_ERR_NOMEM);
return ret;
}
Expand Down Expand Up @@ -2458,14 +2458,13 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {

Local<Array> headers = args[0].As<Array>();
int32_t options = args[1]->Int32Value(env->context()).FromMaybe(0);
Comment thread
jasnell marked this conversation as resolved.
Outdated
Http2Priority priority(env, args[2], args[3], args[4]);

Debug(session, "request submitted");

int32_t ret = 0;
Http2Stream* stream =
session->Http2Session::SubmitRequest(
&priority,
Http2Priority(env, args[2], args[3], args[4]),
Http2Headers(env, headers),
&ret,
static_cast<int>(options));
Expand Down Expand Up @@ -2637,10 +2636,9 @@ void Http2Stream::Priority(const FunctionCallbackInfo<Value>& args) {
Http2Stream* stream;
ASSIGN_OR_RETURN_UNWRAP(&stream, args.Holder());

Http2Priority priority(env, args[0], args[1], args[2]);
bool silent = args[3]->IsTrue();

CHECK_EQ(stream->SubmitPriority(&priority, silent), 0);
CHECK_EQ(stream->SubmitPriority(
Http2Priority(env, args[0], args[1], args[2]),
args[3]->IsTrue()), 0);
Debug(stream, "priority submitted");
}

Expand Down
4 changes: 2 additions & 2 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class Http2Stream : public AsyncWrap,
void OnTrailers();

// Submit a PRIORITY frame for this stream
int SubmitPriority(nghttp2_priority_spec* prispec, bool silent = false);
int SubmitPriority(const Http2Priority& priority, bool silent = false);

// Submits an RST_STREAM frame using the given code
void SubmitRstStream(const uint32_t code);
Expand Down Expand Up @@ -598,7 +598,7 @@ class Http2Session : public AsyncWrap,
// will be a pointer to the Http2Stream instance assigned.
// This only works if the session is a client session.
Http2Stream* SubmitRequest(
nghttp2_priority_spec* prispec,
const Http2Priority& priority,
const Http2Headers& headers,
int32_t* ret,
int options = 0);
Expand Down