2014-04-04 14:57:47 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2016-04-09 11:23:15 +02:00
|
|
|
#include "nghttp2_session.h"
|
|
|
|
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_option_new(nghttp2_option **option_ptr) {
|
2014-04-04 14:57:47 +02:00
|
|
|
*option_ptr = calloc(1, sizeof(nghttp2_option));
|
|
|
|
|
2014-11-27 15:39:04 +01:00
|
|
|
if (*option_ptr == NULL) {
|
2014-04-04 14:57:47 +02:00
|
|
|
return NGHTTP2_ERR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-27 15:39:04 +01:00
|
|
|
void nghttp2_option_del(nghttp2_option *option) { free(option); }
|
2014-04-04 14:57:47 +02:00
|
|
|
|
2014-11-27 15:39:04 +01:00
|
|
|
void nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val) {
|
2014-07-25 14:26:03 +02:00
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE;
|
|
|
|
option->no_auto_window_update = val;
|
2014-04-04 14:57:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option,
|
2014-11-27 15:39:04 +01:00
|
|
|
uint32_t val) {
|
2014-04-04 14:57:47 +02:00
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS;
|
|
|
|
option->peer_max_concurrent_streams = val;
|
|
|
|
}
|
2014-09-13 12:50:44 +02:00
|
|
|
|
2015-04-05 15:35:40 +02:00
|
|
|
void nghttp2_option_set_no_recv_client_magic(nghttp2_option *option, int val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_NO_RECV_CLIENT_MAGIC;
|
|
|
|
option->no_recv_client_magic = val;
|
2014-09-13 12:50:44 +02:00
|
|
|
}
|
2015-02-20 15:26:56 +01:00
|
|
|
|
|
|
|
void nghttp2_option_set_no_http_messaging(nghttp2_option *option, int val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_NO_HTTP_MESSAGING;
|
|
|
|
option->no_http_messaging = val;
|
|
|
|
}
|
2015-08-23 14:22:25 +02:00
|
|
|
|
|
|
|
void nghttp2_option_set_max_reserved_remote_streams(nghttp2_option *option,
|
|
|
|
uint32_t val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_MAX_RESERVED_REMOTE_STREAMS;
|
|
|
|
option->max_reserved_remote_streams = val;
|
|
|
|
}
|
2015-10-14 17:17:07 +02:00
|
|
|
|
2016-04-03 15:58:25 +02:00
|
|
|
static void set_ext_type(uint8_t *ext_types, uint8_t type) {
|
|
|
|
ext_types[type / 8] = (uint8_t)(ext_types[type / 8] | (1 << (type & 0x7)));
|
|
|
|
}
|
|
|
|
|
2015-10-14 17:17:07 +02:00
|
|
|
void nghttp2_option_set_user_recv_extension_type(nghttp2_option *option,
|
|
|
|
uint8_t type) {
|
|
|
|
if (type < 10) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_USER_RECV_EXT_TYPES;
|
2016-04-03 15:58:25 +02:00
|
|
|
set_ext_type(option->user_recv_ext_types, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option,
|
|
|
|
uint8_t type) {
|
2016-04-09 11:23:15 +02:00
|
|
|
switch (type) {
|
|
|
|
case NGHTTP2_ALTSVC:
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
|
|
|
|
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ALTSVC;
|
|
|
|
return;
|
2017-04-24 19:09:16 +02:00
|
|
|
case NGHTTP2_ORIGIN:
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
|
|
|
|
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ORIGIN;
|
|
|
|
return;
|
2016-04-09 11:23:15 +02:00
|
|
|
default:
|
2016-04-03 15:58:25 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-10-14 17:17:07 +02:00
|
|
|
}
|
2016-02-29 15:39:50 +01:00
|
|
|
|
|
|
|
void nghttp2_option_set_no_auto_ping_ack(nghttp2_option *option, int val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_PING_ACK;
|
|
|
|
option->no_auto_ping_ack = val;
|
|
|
|
}
|
2016-06-14 17:00:30 +02:00
|
|
|
|
|
|
|
void nghttp2_option_set_max_send_header_block_length(nghttp2_option *option,
|
|
|
|
size_t val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH;
|
|
|
|
option->max_send_header_block_length = val;
|
|
|
|
}
|
2016-09-11 15:13:59 +02:00
|
|
|
|
|
|
|
void nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option,
|
|
|
|
size_t val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE;
|
|
|
|
option->max_deflate_dynamic_table_size = val;
|
|
|
|
}
|
2017-02-13 14:15:42 +01:00
|
|
|
|
|
|
|
void nghttp2_option_set_no_closed_streams(nghttp2_option *option, int val) {
|
|
|
|
option->opt_set_mask |= NGHTTP2_OPT_NO_CLOSED_STREAMS;
|
|
|
|
option->no_closed_streams = val;
|
|
|
|
}
|