Skip to content

Commit a536572

Browse files
committed
http2: simplify options code, and cleanup
1 parent e80e2e6 commit a536572

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

src/node_http2.cc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,36 @@ Http2Options::Http2Options(Environment* env) {
9595
uint32_t flags = buffer[IDX_OPTIONS_FLAGS];
9696

9797
if (flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)) {
98-
SetMaxDeflateDynamicTableSize(
98+
nghttp2_option_set_max_deflate_dynamic_table_size(
99+
options_,
99100
buffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE]);
100101
}
101102

102103
if (flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)) {
103-
SetMaxReservedRemoteStreams(
104+
nghttp2_option_set_max_reserved_remote_streams(
105+
options_,
104106
buffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS]);
105107
}
106108

107109
if (flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)) {
108-
SetMaxSendHeaderBlockLength(
110+
nghttp2_option_set_max_send_header_block_length(
111+
options_,
109112
buffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH]);
110113
}
111114

112-
SetPeerMaxConcurrentStreams(100); // Recommended default
115+
// Recommended default
116+
nghttp2_option_set_peer_max_concurrent_streams(options_, 100);
113117
if (flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)) {
114-
SetPeerMaxConcurrentStreams(
118+
nghttp2_option_set_peer_max_concurrent_streams(
119+
options_,
115120
buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]);
116121
}
117122

118123
if (flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)) {
119-
SetPaddingStrategy(buffer[IDX_OPTIONS_PADDING_STRATEGY]);
124+
padding_strategy_type strategy =
125+
static_cast<padding_strategy_type>(
126+
buffer[IDX_OPTIONS_PADDING_STRATEGY]);
127+
SetPaddingStrategy(strategy);
120128
}
121129
}
122130

src/node_http2.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,15 @@ class Http2Options {
273273
nghttp2_option_del(options_);
274274
}
275275

276-
nghttp2_option* operator*() {
276+
nghttp2_option* operator*() const {
277277
return options_;
278278
}
279279

280-
void SetPaddingStrategy(uint32_t val) {
280+
void SetPaddingStrategy(padding_strategy_type val) {
281281
CHECK_LE(val, PADDING_STRATEGY_CALLBACK);
282282
padding_strategy_ = static_cast<padding_strategy_type>(val);
283283
}
284284

285-
void SetMaxDeflateDynamicTableSize(size_t val) {
286-
nghttp2_option_set_max_deflate_dynamic_table_size(options_, val);
287-
}
288-
289-
void SetMaxReservedRemoteStreams(uint32_t val) {
290-
nghttp2_option_set_max_reserved_remote_streams(options_, val);
291-
}
292-
293-
void SetMaxSendHeaderBlockLength(size_t val) {
294-
nghttp2_option_set_max_send_header_block_length(options_, val);
295-
}
296-
297-
void SetPeerMaxConcurrentStreams(uint32_t val) {
298-
nghttp2_option_set_peer_max_concurrent_streams(options_, val);
299-
}
300-
301285
padding_strategy_type GetPaddingStrategy() {
302286
return padding_strategy_;
303287
}

src/node_http2_core-inl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,6 @@ Nghttp2Session::Callbacks::Callbacks(bool kHasGetPaddingCallback) {
916916
nghttp2_session_callbacks_set_on_frame_not_send_callback(
917917
callbacks, OnFrameNotSent);
918918

919-
// nghttp2_session_callbacks_set_on_invalid_frame_recv(
920-
// callbacks, OnInvalidFrameReceived);
921-
922919
#ifdef NODE_DEBUG_HTTP2
923920
nghttp2_session_callbacks_set_error_callback(
924921
callbacks, OnNghttpError);

0 commit comments

Comments
 (0)