Path: blob/master/Utilities/cmnghttp2/lib/nghttp2_option.c
3153 views
/*1* nghttp2 - HTTP/2 C Library2*3* Copyright (c) 2014 Tatsuhiro Tsujikawa4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sublicense, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice shall be14* included in all copies or substantial portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND19* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE20* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION21* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*/24#include "nghttp2_option.h"2526#include "nghttp2_session.h"2728int nghttp2_option_new(nghttp2_option **option_ptr) {29*option_ptr = calloc(1, sizeof(nghttp2_option));3031if (*option_ptr == NULL) {32return NGHTTP2_ERR_NOMEM;33}3435return 0;36}3738void nghttp2_option_del(nghttp2_option *option) { free(option); }3940void nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val) {41option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE;42option->no_auto_window_update = val;43}4445void nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option,46uint32_t val) {47option->opt_set_mask |= NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS;48option->peer_max_concurrent_streams = val;49}5051void nghttp2_option_set_no_recv_client_magic(nghttp2_option *option, int val) {52option->opt_set_mask |= NGHTTP2_OPT_NO_RECV_CLIENT_MAGIC;53option->no_recv_client_magic = val;54}5556void nghttp2_option_set_no_http_messaging(nghttp2_option *option, int val) {57option->opt_set_mask |= NGHTTP2_OPT_NO_HTTP_MESSAGING;58option->no_http_messaging = val;59}6061void nghttp2_option_set_max_reserved_remote_streams(nghttp2_option *option,62uint32_t val) {63option->opt_set_mask |= NGHTTP2_OPT_MAX_RESERVED_REMOTE_STREAMS;64option->max_reserved_remote_streams = val;65}6667static void set_ext_type(uint8_t *ext_types, uint8_t type) {68ext_types[type / 8] = (uint8_t)(ext_types[type / 8] | (1 << (type & 0x7)));69}7071void nghttp2_option_set_user_recv_extension_type(nghttp2_option *option,72uint8_t type) {73if (type < 10) {74return;75}7677option->opt_set_mask |= NGHTTP2_OPT_USER_RECV_EXT_TYPES;78set_ext_type(option->user_recv_ext_types, type);79}8081void nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option,82uint8_t type) {83switch (type) {84case NGHTTP2_ALTSVC:85option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;86option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ALTSVC;87return;88case NGHTTP2_ORIGIN:89option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;90option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ORIGIN;91return;92case NGHTTP2_PRIORITY_UPDATE:93option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;94option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_PRIORITY_UPDATE;95return;96default:97return;98}99}100101void nghttp2_option_set_no_auto_ping_ack(nghttp2_option *option, int val) {102option->opt_set_mask |= NGHTTP2_OPT_NO_AUTO_PING_ACK;103option->no_auto_ping_ack = val;104}105106void nghttp2_option_set_max_send_header_block_length(nghttp2_option *option,107size_t val) {108option->opt_set_mask |= NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH;109option->max_send_header_block_length = val;110}111112void nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option,113size_t val) {114option->opt_set_mask |= NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE;115option->max_deflate_dynamic_table_size = val;116}117118void nghttp2_option_set_no_closed_streams(nghttp2_option *option, int val) {119option->opt_set_mask |= NGHTTP2_OPT_NO_CLOSED_STREAMS;120option->no_closed_streams = val;121}122123void nghttp2_option_set_max_outbound_ack(nghttp2_option *option, size_t val) {124option->opt_set_mask |= NGHTTP2_OPT_MAX_OUTBOUND_ACK;125option->max_outbound_ack = val;126}127128void nghttp2_option_set_max_settings(nghttp2_option *option, size_t val) {129option->opt_set_mask |= NGHTTP2_OPT_MAX_SETTINGS;130option->max_settings = val;131}132133void nghttp2_option_set_server_fallback_rfc7540_priorities(134nghttp2_option *option, int val) {135option->opt_set_mask |= NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES;136option->server_fallback_rfc7540_priorities = val;137}138139void nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation(140nghttp2_option *option, int val) {141option->opt_set_mask |=142NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION;143option->no_rfc9113_leading_and_trailing_ws_validation = val;144}145146147