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: simplify options code, and cleanup
  • Loading branch information
jasnell committed Aug 16, 2017
commit a536572970a78f9a129792868cbbb781cfddaaa6
20 changes: 14 additions & 6 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,36 @@ Http2Options::Http2Options(Environment* env) {
uint32_t flags = buffer[IDX_OPTIONS_FLAGS];

if (flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)) {
SetMaxDeflateDynamicTableSize(
nghttp2_option_set_max_deflate_dynamic_table_size(
options_,
buffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE]);
}

if (flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)) {
SetMaxReservedRemoteStreams(
nghttp2_option_set_max_reserved_remote_streams(
options_,
buffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS]);
}

if (flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)) {
SetMaxSendHeaderBlockLength(
nghttp2_option_set_max_send_header_block_length(
options_,
buffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH]);
}

SetPeerMaxConcurrentStreams(100); // Recommended default
// Recommended default
nghttp2_option_set_peer_max_concurrent_streams(options_, 100);
if (flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)) {
SetPeerMaxConcurrentStreams(
nghttp2_option_set_peer_max_concurrent_streams(
options_,
buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]);
}

if (flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)) {
SetPaddingStrategy(buffer[IDX_OPTIONS_PADDING_STRATEGY]);
padding_strategy_type strategy =
static_cast<padding_strategy_type>(
buffer[IDX_OPTIONS_PADDING_STRATEGY]);
SetPaddingStrategy(strategy);
}
}

Expand Down
20 changes: 2 additions & 18 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,15 @@ class Http2Options {
nghttp2_option_del(options_);
}

nghttp2_option* operator*() {
nghttp2_option* operator*() const {
return options_;
}

void SetPaddingStrategy(uint32_t val) {
void SetPaddingStrategy(padding_strategy_type val) {
CHECK_LE(val, PADDING_STRATEGY_CALLBACK);
padding_strategy_ = static_cast<padding_strategy_type>(val);
}

void SetMaxDeflateDynamicTableSize(size_t val) {
nghttp2_option_set_max_deflate_dynamic_table_size(options_, val);
}

void SetMaxReservedRemoteStreams(uint32_t val) {
nghttp2_option_set_max_reserved_remote_streams(options_, val);
}

void SetMaxSendHeaderBlockLength(size_t val) {
nghttp2_option_set_max_send_header_block_length(options_, val);
}

void SetPeerMaxConcurrentStreams(uint32_t val) {
nghttp2_option_set_peer_max_concurrent_streams(options_, val);
}

padding_strategy_type GetPaddingStrategy() {
return padding_strategy_;
}
Expand Down
3 changes: 0 additions & 3 deletions src/node_http2_core-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,6 @@ Nghttp2Session::Callbacks::Callbacks(bool kHasGetPaddingCallback) {
nghttp2_session_callbacks_set_on_frame_not_send_callback(
callbacks, OnFrameNotSent);

// nghttp2_session_callbacks_set_on_invalid_frame_recv(
// callbacks, OnInvalidFrameReceived);

#ifdef NODE_DEBUG_HTTP2
nghttp2_session_callbacks_set_error_callback(
callbacks, OnNghttpError);
Expand Down