Hide session option from public API
To make adding new option easier, we decided to make the details of option struct private and hide it from public API. We provide functions to set individual option value.
This commit is contained in:
parent
21ab2f135b
commit
d668d2448b
|
@ -40,7 +40,8 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
|
|||
nghttp2_npn.c nghttp2_gzip.c \
|
||||
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c \
|
||||
nghttp2_version.c \
|
||||
nghttp2_priority_spec.c
|
||||
nghttp2_priority_spec.c \
|
||||
nghttp2_option.c
|
||||
|
||||
HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
|
||||
nghttp2_frame.h \
|
||||
|
@ -50,7 +51,8 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
|
|||
nghttp2_submit.h nghttp2_outbound_item.h \
|
||||
nghttp2_net.h \
|
||||
nghttp2_hd.h nghttp2_hd_huffman.h \
|
||||
nghttp2_priority_spec.h
|
||||
nghttp2_priority_spec.h \
|
||||
nghttp2_option.h
|
||||
|
||||
libnghttp2_la_SOURCES = $(HFILES) $(OBJECTS)
|
||||
libnghttp2_la_LDFLAGS = -no-undefined \
|
||||
|
|
|
@ -1543,80 +1543,20 @@ int nghttp2_session_server_new(nghttp2_session **session_ptr,
|
|||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @enum
|
||||
*
|
||||
* Configuration options for :type:`nghttp2_session`.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* stream automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a stream and the application
|
||||
* is responsible for sending WINDOW_UPDATE using
|
||||
* `nghttp2_submit_window_update`. By default, this option is set to
|
||||
* zero.
|
||||
*/
|
||||
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE = 1,
|
||||
/**
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* connection automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a connection and the
|
||||
* application is responsible for sending WINDOW_UPDATE with stream
|
||||
* ID 0 using `nghttp2_submit_window_update`. By default, this
|
||||
* option is set to zero.
|
||||
*/
|
||||
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE = 1 << 1,
|
||||
/**
|
||||
* This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
|
||||
* remote endpoint as if it is received in SETTINGS frame. Without
|
||||
* specifying this option, before the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
|
||||
* endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
|
||||
* cause problem if local endpoint submits lots of requests
|
||||
* initially and sending them at once to the remote peer may lead to
|
||||
* the rejection of some requests. Specifying this option to the
|
||||
* sensible value, say 100, may avoid this kind of issue. This value
|
||||
* will be overwritten if the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint.
|
||||
*/
|
||||
NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS = 1 << 2
|
||||
} nghttp2_opt;
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
* Struct to store option values for nghttp2_session.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* :enum:`NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS`
|
||||
*/
|
||||
uint32_t peer_max_concurrent_streams;
|
||||
/**
|
||||
* :enum:`NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE`
|
||||
*/
|
||||
uint8_t no_auto_stream_window_update;
|
||||
/**
|
||||
* :enum:`NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE`
|
||||
*/
|
||||
uint8_t no_auto_connection_window_update;
|
||||
} nghttp2_opt_set;
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Like `nghttp2_session_client_new()`, but with additional options
|
||||
* specified in the |opt_set|. The caller must set bitwise-OR of
|
||||
* :enum:`nghttp2_opt` for given options. For example, if it
|
||||
* specifies :enum:`NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE` and
|
||||
* :enum:`NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS` in the |opt_set|,
|
||||
* the |opt_set_mask| should be
|
||||
* ``NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE |
|
||||
* NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS``.
|
||||
* specified in the |option|.
|
||||
*
|
||||
* If the |opt_set_mask| is 0, the |opt_set| could be ``NULL`` safely
|
||||
* and the call is equivalent to `nghttp2_session_client_new()`.
|
||||
* The |option| can be ``NULL`` and the call is equivalent to
|
||||
* `nghttp2_session_client_new()`.
|
||||
*
|
||||
* This function does not take ownership |option|. The application is
|
||||
* responsible for freeing |option| if it finishes using the object.
|
||||
*
|
||||
* The library code does not refer to |option| after this function
|
||||
* returns.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
|
@ -1627,23 +1567,22 @@ typedef struct {
|
|||
int nghttp2_session_client_new2(nghttp2_session **session_ptr,
|
||||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data,
|
||||
uint32_t opt_set_mask,
|
||||
const nghttp2_opt_set *opt_set);
|
||||
const nghttp2_option *option);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Like `nghttp2_session_server_new()`, but with additional options
|
||||
* specified in the |opt_set|. The caller must set bitwise-OR of
|
||||
* :enum:`nghttp2_opt` for given options. For example, if it
|
||||
* specifies :enum:`NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE` and
|
||||
* :enum:`NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS` in the |opt_set|,
|
||||
* the |opt_set_mask| should be
|
||||
* ``NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE |
|
||||
* NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS``.
|
||||
* specified in the |option|.
|
||||
*
|
||||
* If the |opt_set_mask| is 0, the |opt_set| could be ``NULL`` safely
|
||||
* and the call is equivalent to `nghttp2_session_server_new()`.
|
||||
* The |option| can be ``NULL`` and the call is equivalent to
|
||||
* `nghttp2_session_server_new()`.
|
||||
*
|
||||
* This function does not take ownership |option|. The application is
|
||||
* responsible for freeing |option| if it finishes using the object.
|
||||
*
|
||||
* The library code does not refer to |option| after this function
|
||||
* returns.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
|
@ -1654,8 +1593,7 @@ int nghttp2_session_client_new2(nghttp2_session **session_ptr,
|
|||
int nghttp2_session_server_new2(nghttp2_session **session_ptr,
|
||||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data,
|
||||
uint32_t opt_set_mask,
|
||||
const nghttp2_opt_set *opt_set);
|
||||
const nghttp2_option *option);
|
||||
|
||||
/**
|
||||
* @function
|
||||
|
@ -1665,6 +1603,84 @@ int nghttp2_session_server_new2(nghttp2_session **session_ptr,
|
|||
*/
|
||||
void nghttp2_session_del(nghttp2_session *session);
|
||||
|
||||
struct nghttp2_option;
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
* Configuration options for :type:`nghttp2_session`. The details of
|
||||
* this structure are intentionally hidden from the public API.
|
||||
*/
|
||||
typedef struct nghttp2_option nghttp2_option;
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Initializes |*option_ptr| with default values.
|
||||
*
|
||||
* When the application finished using this object, it can use
|
||||
* `nghttp2_option_del()` to free its memory.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
*/
|
||||
int nghttp2_option_new(nghttp2_option **option_ptr);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Frees any resources allocated for |option|. If |option| is
|
||||
* ``NULL``, this function does nothing.
|
||||
*/
|
||||
void nghttp2_option_del(nghttp2_option *option);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* stream automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a stream and the application
|
||||
* is responsible for sending WINDOW_UPDATE using
|
||||
* `nghttp2_submit_window_update`. By default, this option is set to
|
||||
* zero.
|
||||
*/
|
||||
void nghttp2_option_set_no_auto_stream_window_update(nghttp2_option *option,
|
||||
int val);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* connection automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a connection and the
|
||||
* application is responsible for sending WINDOW_UPDATE with stream
|
||||
* ID 0 using `nghttp2_submit_window_update`. By default, this
|
||||
* option is set to zero.
|
||||
*/
|
||||
void nghttp2_option_set_no_auto_connection_window_update
|
||||
(nghttp2_option *option, int val);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
|
||||
* remote endpoint as if it is received in SETTINGS frame. Without
|
||||
* specifying this option, before the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
|
||||
* endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
|
||||
* cause problem if local endpoint submits lots of requests
|
||||
* initially and sending them at once to the remote peer may lead to
|
||||
* the rejection of some requests. Specifying this option to the
|
||||
* sensible value, say 100, may avoid this kind of issue. This value
|
||||
* will be overwritten if the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint.
|
||||
*/
|
||||
void nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option,
|
||||
uint32_t val);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* nghttp2 - HTTP/2 C Library
|
||||
*
|
||||
* Copyright (c) 2014 Tatsuhiro Tsujikawa
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "nghttp2_option.h"
|
||||
|
||||
int nghttp2_option_new(nghttp2_option **option_ptr)
|
||||
{
|
||||
*option_ptr = calloc(1, sizeof(nghttp2_option));
|
||||
|
||||
if(*option_ptr == NULL) {
|
||||
return NGHTTP2_ERR_NOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nghttp2_option_del(nghttp2_option *option)
|
||||
{
|
||||
free(option);
|
||||
}
|
||||
|
||||
void nghttp2_option_set_no_auto_stream_window_update(nghttp2_option *option,
|
||||
int val)
|
||||
{
|
||||
option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE;
|
||||
option->no_auto_stream_window_update = val;
|
||||
}
|
||||
|
||||
void nghttp2_option_set_no_auto_connection_window_update
|
||||
(nghttp2_option *option, int val)
|
||||
{
|
||||
option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE;
|
||||
option->no_auto_connection_window_update = val;
|
||||
}
|
||||
|
||||
void nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option,
|
||||
uint32_t val)
|
||||
{
|
||||
option->opt_set_mask |= NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS;
|
||||
option->peer_max_concurrent_streams = val;
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* nghttp2 - HTTP/2 C Library
|
||||
*
|
||||
* Copyright (c) 2014 Tatsuhiro Tsujikawa
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef NGHTTP2_OPTION_H
|
||||
#define NGHTTP2_OPTION_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
/**
|
||||
* Configuration options
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* stream automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a stream and the application
|
||||
* is responsible for sending WINDOW_UPDATE using
|
||||
* `nghttp2_submit_window_update`. By default, this option is set to
|
||||
* zero.
|
||||
*/
|
||||
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE = 1,
|
||||
/**
|
||||
* This option prevents the library from sending WINDOW_UPDATE for a
|
||||
* connection automatically. If this option is set to nonzero, the
|
||||
* library won't send WINDOW_UPDATE for a connection and the
|
||||
* application is responsible for sending WINDOW_UPDATE with stream
|
||||
* ID 0 using `nghttp2_submit_window_update`. By default, this
|
||||
* option is set to zero.
|
||||
*/
|
||||
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE = 1 << 1,
|
||||
/**
|
||||
* This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
|
||||
* remote endpoint as if it is received in SETTINGS frame. Without
|
||||
* specifying this option, before the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
|
||||
* endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
|
||||
* cause problem if local endpoint submits lots of requests
|
||||
* initially and sending them at once to the remote peer may lead to
|
||||
* the rejection of some requests. Specifying this option to the
|
||||
* sensible value, say 100, may avoid this kind of issue. This value
|
||||
* will be overwritten if the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint.
|
||||
*/
|
||||
NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS = 1 << 2
|
||||
} nghttp2_option_flag;
|
||||
|
||||
/**
|
||||
* Struct to store option values for nghttp2_session.
|
||||
*/
|
||||
struct nghttp2_option {
|
||||
/**
|
||||
* Bitwise OR of nghttp2_option_flag to determine that which fields
|
||||
* are specified.
|
||||
*/
|
||||
uint32_t opt_set_mask;
|
||||
/**
|
||||
* NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS
|
||||
*/
|
||||
uint32_t peer_max_concurrent_streams;
|
||||
/**
|
||||
* NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE
|
||||
*/
|
||||
uint8_t no_auto_stream_window_update;
|
||||
/**
|
||||
* NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE
|
||||
*/
|
||||
uint8_t no_auto_connection_window_update;
|
||||
};
|
||||
|
||||
#endif /* NGHTTP2_OPTION_H */
|
|
@ -32,6 +32,7 @@
|
|||
#include "nghttp2_helper.h"
|
||||
#include "nghttp2_net.h"
|
||||
#include "nghttp2_priority_spec.h"
|
||||
#include "nghttp2_option.h"
|
||||
|
||||
/*
|
||||
* Returns non-zero if the number of outgoing opened streams is larger
|
||||
|
@ -251,8 +252,7 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
|
|||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data,
|
||||
int server,
|
||||
uint32_t opt_set_mask,
|
||||
const nghttp2_opt_set *opt_set)
|
||||
const nghttp2_option *option)
|
||||
{
|
||||
int rv;
|
||||
|
||||
|
@ -294,16 +294,6 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
|
|||
|
||||
(*session_ptr)->next_seq = 0;
|
||||
|
||||
if((opt_set_mask & NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE) &&
|
||||
opt_set->no_auto_stream_window_update) {
|
||||
(*session_ptr)->opt_flags |= NGHTTP2_OPTMASK_NO_AUTO_STREAM_WINDOW_UPDATE;
|
||||
}
|
||||
if((opt_set_mask & NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE) &&
|
||||
opt_set->no_auto_connection_window_update) {
|
||||
(*session_ptr)->opt_flags |=
|
||||
NGHTTP2_OPTMASK_NO_AUTO_CONNECTION_WINDOW_UPDATE;
|
||||
}
|
||||
|
||||
(*session_ptr)->remote_window_size = NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE;
|
||||
(*session_ptr)->recv_window_size = 0;
|
||||
(*session_ptr)->recv_reduction = 0;
|
||||
|
@ -334,9 +324,31 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
|
|||
init_settings((*session_ptr)->remote_settings);
|
||||
init_settings((*session_ptr)->local_settings);
|
||||
|
||||
if(opt_set_mask & NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS) {
|
||||
(*session_ptr)->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] =
|
||||
opt_set->peer_max_concurrent_streams;
|
||||
|
||||
if(option) {
|
||||
if((option->opt_set_mask & NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE) &&
|
||||
option->no_auto_stream_window_update) {
|
||||
|
||||
(*session_ptr)->opt_flags |=
|
||||
NGHTTP2_OPTMASK_NO_AUTO_STREAM_WINDOW_UPDATE;
|
||||
|
||||
}
|
||||
|
||||
if((option->opt_set_mask & NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE) &&
|
||||
option->no_auto_connection_window_update) {
|
||||
|
||||
(*session_ptr)->opt_flags |=
|
||||
NGHTTP2_OPTMASK_NO_AUTO_CONNECTION_WINDOW_UPDATE;
|
||||
|
||||
}
|
||||
|
||||
if(option->opt_set_mask & NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS) {
|
||||
|
||||
(*session_ptr)->
|
||||
remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] =
|
||||
option->peer_max_concurrent_streams;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
(*session_ptr)->callbacks = *callbacks;
|
||||
|
@ -368,20 +380,18 @@ int nghttp2_session_client_new(nghttp2_session **session_ptr,
|
|||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
return nghttp2_session_client_new2(session_ptr, callbacks, user_data,
|
||||
0, NULL);
|
||||
return nghttp2_session_client_new2(session_ptr, callbacks, user_data, NULL);
|
||||
}
|
||||
|
||||
int nghttp2_session_client_new2(nghttp2_session **session_ptr,
|
||||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data,
|
||||
uint32_t opt_set_mask,
|
||||
const nghttp2_opt_set *opt_set)
|
||||
const nghttp2_option *option)
|
||||
{
|
||||
int rv;
|
||||
/* For client side session, header compression is disabled. */
|
||||
rv = nghttp2_session_new(session_ptr, callbacks, user_data, 0,
|
||||
opt_set_mask, opt_set);
|
||||
rv = nghttp2_session_new(session_ptr, callbacks, user_data, 0, option);
|
||||
|
||||
if(rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -394,20 +404,18 @@ int nghttp2_session_server_new(nghttp2_session **session_ptr,
|
|||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
return nghttp2_session_server_new2(session_ptr, callbacks, user_data,
|
||||
0, NULL);
|
||||
return nghttp2_session_server_new2(session_ptr, callbacks, user_data, NULL);
|
||||
}
|
||||
|
||||
int nghttp2_session_server_new2(nghttp2_session **session_ptr,
|
||||
const nghttp2_session_callbacks *callbacks,
|
||||
void *user_data,
|
||||
uint32_t opt_set_mask,
|
||||
const nghttp2_opt_set *opt_set)
|
||||
const nghttp2_option *option)
|
||||
{
|
||||
int rv;
|
||||
/* Enable header compression on server side. */
|
||||
rv = nghttp2_session_new(session_ptr, callbacks, user_data, 1,
|
||||
opt_set_mask, opt_set);
|
||||
rv = nghttp2_session_new(session_ptr, callbacks, user_data, 1, option);
|
||||
|
||||
if(rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ struct Config {
|
|||
std::string certfile;
|
||||
std::string keyfile;
|
||||
std::string datafile;
|
||||
nghttp2_option *http2_option;
|
||||
size_t output_upper_thres;
|
||||
size_t padding;
|
||||
ssize_t peer_max_concurrent_streams;
|
||||
|
@ -115,7 +116,17 @@ struct Config {
|
|||
stat(false),
|
||||
upgrade(false),
|
||||
continuation(false)
|
||||
{}
|
||||
{
|
||||
nghttp2_option_new(&http2_option);
|
||||
nghttp2_option_set_peer_max_concurrent_streams
|
||||
(http2_option,
|
||||
peer_max_concurrent_streams);
|
||||
}
|
||||
|
||||
~Config()
|
||||
{
|
||||
nghttp2_option_del(http2_option);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
@ -686,11 +697,10 @@ struct HttpClient {
|
|||
if(!need_upgrade()) {
|
||||
record_handshake_time();
|
||||
}
|
||||
nghttp2_opt_set opt_set;
|
||||
opt_set.peer_max_concurrent_streams = config.peer_max_concurrent_streams;
|
||||
|
||||
rv = nghttp2_session_client_new2(&session, callbacks, this,
|
||||
NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS,
|
||||
&opt_set);
|
||||
config.http2_option);
|
||||
|
||||
if(rv != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2018,6 +2028,9 @@ int main(int argc, char **argv)
|
|||
|
||||
set_color_output(color || isatty(fileno(stdout)));
|
||||
|
||||
nghttp2_option_set_peer_max_concurrent_streams
|
||||
(config.http2_option, config.peer_max_concurrent_streams);
|
||||
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_IGN;
|
||||
|
|
|
@ -451,6 +451,13 @@ void fill_default_config()
|
|||
mod_config()->altsvc_host_len = 0;
|
||||
mod_config()->altsvc_origin = nullptr;
|
||||
mod_config()->altsvc_origin_len = 0;
|
||||
|
||||
nghttp2_option_new(&mod_config()->http2_option);
|
||||
|
||||
nghttp2_option_set_no_auto_stream_window_update
|
||||
(mod_config()->http2_option, 1);
|
||||
nghttp2_option_set_no_auto_connection_window_update
|
||||
(mod_config()->http2_option, 1);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include <event.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
namespace shrpx {
|
||||
|
||||
namespace ssl {
|
||||
|
@ -177,6 +179,7 @@ struct Config {
|
|||
char *altsvc_protocol_id;
|
||||
char *altsvc_host;
|
||||
char *altsvc_origin;
|
||||
nghttp2_option *http2_option;
|
||||
size_t downstream_addrlen;
|
||||
size_t num_worker;
|
||||
size_t http2_max_concurrent_streams;
|
||||
|
|
|
@ -1206,14 +1206,9 @@ int Http2Session::on_connect()
|
|||
callbacks.select_padding_callback = http::select_padding_callback;
|
||||
}
|
||||
|
||||
nghttp2_opt_set opt_set;
|
||||
opt_set.no_auto_stream_window_update = 1;
|
||||
opt_set.no_auto_connection_window_update = 1;
|
||||
uint32_t opt_set_mask =
|
||||
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE |
|
||||
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE;
|
||||
rv = nghttp2_session_client_new2(&session_, &callbacks, this,
|
||||
opt_set_mask, &opt_set);
|
||||
get_config()->http2_option);
|
||||
|
||||
if(rv != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -508,15 +508,10 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
|
|||
callbacks.select_padding_callback = http::select_padding_callback;
|
||||
}
|
||||
|
||||
nghttp2_opt_set opt_set;
|
||||
opt_set.no_auto_stream_window_update = 1;
|
||||
opt_set.no_auto_connection_window_update = 1;
|
||||
uint32_t opt_set_mask =
|
||||
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE |
|
||||
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE;
|
||||
int rv;
|
||||
rv = nghttp2_session_server_new2(&session_, &callbacks, this,
|
||||
opt_set_mask, &opt_set);
|
||||
get_config()->http2_option);
|
||||
|
||||
assert(rv == 0);
|
||||
|
||||
flow_control_ = true;
|
||||
|
|
Loading…
Reference in New Issue