11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * nghttp2 - HTTP/2 C Library 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Copyright (c) 2012 Tatsuhiro Tsujikawa 51cb0ef41Sopenharmony_ci * 61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 71cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the 81cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 91cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 101cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 111cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 121cb0ef41Sopenharmony_ci * the following conditions: 131cb0ef41Sopenharmony_ci * 141cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be 151cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software. 161cb0ef41Sopenharmony_ci * 171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 181cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 191cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 201cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 211cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 221cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 231cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 241cb0ef41Sopenharmony_ci */ 251cb0ef41Sopenharmony_ci#ifndef NGHTTP2_STREAM_H 261cb0ef41Sopenharmony_ci#define NGHTTP2_STREAM_H 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci#ifdef HAVE_CONFIG_H 291cb0ef41Sopenharmony_ci# include <config.h> 301cb0ef41Sopenharmony_ci#endif /* HAVE_CONFIG_H */ 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci#include <nghttp2/nghttp2.h> 331cb0ef41Sopenharmony_ci#include "nghttp2_outbound_item.h" 341cb0ef41Sopenharmony_ci#include "nghttp2_map.h" 351cb0ef41Sopenharmony_ci#include "nghttp2_pq.h" 361cb0ef41Sopenharmony_ci#include "nghttp2_int.h" 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci/* 391cb0ef41Sopenharmony_ci * If local peer is stream initiator: 401cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_OPENING : upon sending request HEADERS 411cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_OPENED : upon receiving response HEADERS 421cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_CLOSING : upon queuing RST_STREAM 431cb0ef41Sopenharmony_ci * 441cb0ef41Sopenharmony_ci * If remote peer is stream initiator: 451cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_OPENING : upon receiving request HEADERS 461cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_OPENED : upon sending response HEADERS 471cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_CLOSING : upon queuing RST_STREAM 481cb0ef41Sopenharmony_ci */ 491cb0ef41Sopenharmony_citypedef enum { 501cb0ef41Sopenharmony_ci /* Initial state */ 511cb0ef41Sopenharmony_ci NGHTTP2_STREAM_INITIAL, 521cb0ef41Sopenharmony_ci /* For stream initiator: request HEADERS has been sent, but response 531cb0ef41Sopenharmony_ci HEADERS has not been received yet. For receiver: request HEADERS 541cb0ef41Sopenharmony_ci has been received, but it does not send response HEADERS yet. */ 551cb0ef41Sopenharmony_ci NGHTTP2_STREAM_OPENING, 561cb0ef41Sopenharmony_ci /* For stream initiator: response HEADERS is received. For receiver: 571cb0ef41Sopenharmony_ci response HEADERS is sent. */ 581cb0ef41Sopenharmony_ci NGHTTP2_STREAM_OPENED, 591cb0ef41Sopenharmony_ci /* RST_STREAM is received, but somehow we need to keep stream in 601cb0ef41Sopenharmony_ci memory. */ 611cb0ef41Sopenharmony_ci NGHTTP2_STREAM_CLOSING, 621cb0ef41Sopenharmony_ci /* PUSH_PROMISE is received or sent */ 631cb0ef41Sopenharmony_ci NGHTTP2_STREAM_RESERVED, 641cb0ef41Sopenharmony_ci /* Stream is created in this state if it is used as anchor in 651cb0ef41Sopenharmony_ci dependency tree. */ 661cb0ef41Sopenharmony_ci NGHTTP2_STREAM_IDLE 671cb0ef41Sopenharmony_ci} nghttp2_stream_state; 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_citypedef enum { 701cb0ef41Sopenharmony_ci NGHTTP2_SHUT_NONE = 0, 711cb0ef41Sopenharmony_ci /* Indicates further receptions will be disallowed. */ 721cb0ef41Sopenharmony_ci NGHTTP2_SHUT_RD = 0x01, 731cb0ef41Sopenharmony_ci /* Indicates further transmissions will be disallowed. */ 741cb0ef41Sopenharmony_ci NGHTTP2_SHUT_WR = 0x02, 751cb0ef41Sopenharmony_ci /* Indicates both further receptions and transmissions will be 761cb0ef41Sopenharmony_ci disallowed. */ 771cb0ef41Sopenharmony_ci NGHTTP2_SHUT_RDWR = NGHTTP2_SHUT_RD | NGHTTP2_SHUT_WR 781cb0ef41Sopenharmony_ci} nghttp2_shut_flag; 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_citypedef enum { 811cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_NONE = 0, 821cb0ef41Sopenharmony_ci /* Indicates that this stream is pushed stream and not opened 831cb0ef41Sopenharmony_ci yet. */ 841cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_PUSH = 0x01, 851cb0ef41Sopenharmony_ci /* Indicates that this stream was closed */ 861cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_CLOSED = 0x02, 871cb0ef41Sopenharmony_ci /* Indicates the item is deferred due to flow control. */ 881cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL = 0x04, 891cb0ef41Sopenharmony_ci /* Indicates the item is deferred by user callback */ 901cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_DEFERRED_USER = 0x08, 911cb0ef41Sopenharmony_ci /* bitwise OR of NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL and 921cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_DEFERRED_USER. */ 931cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c, 941cb0ef41Sopenharmony_ci /* Indicates that this stream is not subject to RFC7540 951cb0ef41Sopenharmony_ci priorities scheme. */ 961cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES = 0x10, 971cb0ef41Sopenharmony_ci /* Ignore client RFC 9218 priority signal. */ 981cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES = 0x20, 991cb0ef41Sopenharmony_ci /* Indicates that RFC 9113 leading and trailing white spaces 1001cb0ef41Sopenharmony_ci validation against a field value is not performed. */ 1011cb0ef41Sopenharmony_ci NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 0x40, 1021cb0ef41Sopenharmony_ci} nghttp2_stream_flag; 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci/* HTTP related flags to enforce HTTP semantics */ 1051cb0ef41Sopenharmony_citypedef enum { 1061cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_NONE = 0, 1071cb0ef41Sopenharmony_ci /* header field seen so far */ 1081cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__AUTHORITY = 1, 1091cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__PATH = 1 << 1, 1101cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__METHOD = 1 << 2, 1111cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__SCHEME = 1 << 3, 1121cb0ef41Sopenharmony_ci /* host is not pseudo header, but we require either host or 1131cb0ef41Sopenharmony_ci :authority */ 1141cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_HOST = 1 << 4, 1151cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__STATUS = 1 << 5, 1161cb0ef41Sopenharmony_ci /* required header fields for HTTP request except for CONNECT 1171cb0ef41Sopenharmony_ci method. */ 1181cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_REQ_HEADERS = NGHTTP2_HTTP_FLAG__METHOD | 1191cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__PATH | 1201cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__SCHEME, 1211cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED = 1 << 6, 1221cb0ef41Sopenharmony_ci /* HTTP method flags */ 1231cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_CONNECT = 1 << 7, 1241cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_HEAD = 1 << 8, 1251cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_OPTIONS = 1 << 9, 1261cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND = 1 << 10, 1271cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_ALL = NGHTTP2_HTTP_FLAG_METH_CONNECT | 1281cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_HEAD | 1291cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_OPTIONS | 1301cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND, 1311cb0ef41Sopenharmony_ci /* :path category */ 1321cb0ef41Sopenharmony_ci /* path starts with "/" */ 1331cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_PATH_REGULAR = 1 << 11, 1341cb0ef41Sopenharmony_ci /* path "*" */ 1351cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_PATH_ASTERISK = 1 << 12, 1361cb0ef41Sopenharmony_ci /* scheme */ 1371cb0ef41Sopenharmony_ci /* "http" or "https" scheme */ 1381cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_SCHEME_HTTP = 1 << 13, 1391cb0ef41Sopenharmony_ci /* set if final response is expected */ 1401cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14, 1411cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15, 1421cb0ef41Sopenharmony_ci /* set if priority header field is received */ 1431cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_PRIORITY = 1 << 16, 1441cb0ef41Sopenharmony_ci /* set if an error is encountered while parsing priority header 1451cb0ef41Sopenharmony_ci field */ 1461cb0ef41Sopenharmony_ci NGHTTP2_HTTP_FLAG_BAD_PRIORITY = 1 << 17, 1471cb0ef41Sopenharmony_ci} nghttp2_http_flag; 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_cistruct nghttp2_stream { 1501cb0ef41Sopenharmony_ci /* Entry for dep_prev->obq */ 1511cb0ef41Sopenharmony_ci nghttp2_pq_entry pq_entry; 1521cb0ef41Sopenharmony_ci /* Priority Queue storing direct descendant (nghttp2_stream). Only 1531cb0ef41Sopenharmony_ci streams which itself has some data to send, or has a descendant 1541cb0ef41Sopenharmony_ci which has some data to sent. */ 1551cb0ef41Sopenharmony_ci nghttp2_pq obq; 1561cb0ef41Sopenharmony_ci /* Content-Length of request/response body. -1 if unknown. */ 1571cb0ef41Sopenharmony_ci int64_t content_length; 1581cb0ef41Sopenharmony_ci /* Received body so far */ 1591cb0ef41Sopenharmony_ci int64_t recv_content_length; 1601cb0ef41Sopenharmony_ci /* Base last_cycle for direct descendent streams. */ 1611cb0ef41Sopenharmony_ci uint64_t descendant_last_cycle; 1621cb0ef41Sopenharmony_ci /* Next scheduled time to sent item */ 1631cb0ef41Sopenharmony_ci uint64_t cycle; 1641cb0ef41Sopenharmony_ci /* Next seq used for direct descendant streams */ 1651cb0ef41Sopenharmony_ci uint64_t descendant_next_seq; 1661cb0ef41Sopenharmony_ci /* Secondary key for prioritization to break a tie for cycle. This 1671cb0ef41Sopenharmony_ci value is monotonically increased for single parent stream. */ 1681cb0ef41Sopenharmony_ci uint64_t seq; 1691cb0ef41Sopenharmony_ci /* pointers to form dependency tree. If multiple streams depend on 1701cb0ef41Sopenharmony_ci a stream, only one stream (left most) has non-NULL dep_prev which 1711cb0ef41Sopenharmony_ci points to the stream it depends on. The remaining streams are 1721cb0ef41Sopenharmony_ci linked using sib_prev and sib_next. The stream which has 1731cb0ef41Sopenharmony_ci non-NULL dep_prev always NULL sib_prev. The right most stream 1741cb0ef41Sopenharmony_ci has NULL sib_next. If this stream is a root of dependency tree, 1751cb0ef41Sopenharmony_ci dep_prev and sib_prev are NULL. */ 1761cb0ef41Sopenharmony_ci nghttp2_stream *dep_prev, *dep_next; 1771cb0ef41Sopenharmony_ci nghttp2_stream *sib_prev, *sib_next; 1781cb0ef41Sopenharmony_ci /* When stream is kept after closure, it may be kept in doubly 1791cb0ef41Sopenharmony_ci linked list pointed by nghttp2_session closed_stream_head. 1801cb0ef41Sopenharmony_ci closed_next points to the next stream object if it is the element 1811cb0ef41Sopenharmony_ci of the list. */ 1821cb0ef41Sopenharmony_ci nghttp2_stream *closed_prev, *closed_next; 1831cb0ef41Sopenharmony_ci /* The arbitrary data provided by user for this stream. */ 1841cb0ef41Sopenharmony_ci void *stream_user_data; 1851cb0ef41Sopenharmony_ci /* Item to send */ 1861cb0ef41Sopenharmony_ci nghttp2_outbound_item *item; 1871cb0ef41Sopenharmony_ci /* Last written length of frame payload */ 1881cb0ef41Sopenharmony_ci size_t last_writelen; 1891cb0ef41Sopenharmony_ci /* stream ID */ 1901cb0ef41Sopenharmony_ci int32_t stream_id; 1911cb0ef41Sopenharmony_ci /* Current remote window size. This value is computed against the 1921cb0ef41Sopenharmony_ci current initial window size of remote endpoint. */ 1931cb0ef41Sopenharmony_ci int32_t remote_window_size; 1941cb0ef41Sopenharmony_ci /* Keep track of the number of bytes received without 1951cb0ef41Sopenharmony_ci WINDOW_UPDATE. This could be negative after submitting negative 1961cb0ef41Sopenharmony_ci value to WINDOW_UPDATE */ 1971cb0ef41Sopenharmony_ci int32_t recv_window_size; 1981cb0ef41Sopenharmony_ci /* The number of bytes consumed by the application and now is 1991cb0ef41Sopenharmony_ci subject to WINDOW_UPDATE. This is only used when auto 2001cb0ef41Sopenharmony_ci WINDOW_UPDATE is turned off. */ 2011cb0ef41Sopenharmony_ci int32_t consumed_size; 2021cb0ef41Sopenharmony_ci /* The amount of recv_window_size cut using submitting negative 2031cb0ef41Sopenharmony_ci value to WINDOW_UPDATE */ 2041cb0ef41Sopenharmony_ci int32_t recv_reduction; 2051cb0ef41Sopenharmony_ci /* window size for local flow control. It is initially set to 2061cb0ef41Sopenharmony_ci NGHTTP2_INITIAL_WINDOW_SIZE and could be increased/decreased by 2071cb0ef41Sopenharmony_ci submitting WINDOW_UPDATE. See nghttp2_submit_window_update(). */ 2081cb0ef41Sopenharmony_ci int32_t local_window_size; 2091cb0ef41Sopenharmony_ci /* weight of this stream */ 2101cb0ef41Sopenharmony_ci int32_t weight; 2111cb0ef41Sopenharmony_ci /* This is unpaid penalty (offset) when calculating cycle. */ 2121cb0ef41Sopenharmony_ci uint32_t pending_penalty; 2131cb0ef41Sopenharmony_ci /* sum of weight of direct descendants */ 2141cb0ef41Sopenharmony_ci int32_t sum_dep_weight; 2151cb0ef41Sopenharmony_ci nghttp2_stream_state state; 2161cb0ef41Sopenharmony_ci /* status code from remote server */ 2171cb0ef41Sopenharmony_ci int16_t status_code; 2181cb0ef41Sopenharmony_ci /* Bitwise OR of zero or more nghttp2_http_flag values */ 2191cb0ef41Sopenharmony_ci uint32_t http_flags; 2201cb0ef41Sopenharmony_ci /* This is bitwise-OR of 0 or more of nghttp2_stream_flag. */ 2211cb0ef41Sopenharmony_ci uint8_t flags; 2221cb0ef41Sopenharmony_ci /* Bitwise OR of zero or more nghttp2_shut_flag values */ 2231cb0ef41Sopenharmony_ci uint8_t shut_flags; 2241cb0ef41Sopenharmony_ci /* Nonzero if this stream has been queued to stream pointed by 2251cb0ef41Sopenharmony_ci dep_prev. We maintain the invariant that if a stream is queued, 2261cb0ef41Sopenharmony_ci then its ancestors, except for root, are also queued. This 2271cb0ef41Sopenharmony_ci invariant may break in fatal error condition. */ 2281cb0ef41Sopenharmony_ci uint8_t queued; 2291cb0ef41Sopenharmony_ci /* This flag is used to reduce excessive queuing of WINDOW_UPDATE to 2301cb0ef41Sopenharmony_ci this stream. The nonzero does not necessarily mean WINDOW_UPDATE 2311cb0ef41Sopenharmony_ci is not queued. */ 2321cb0ef41Sopenharmony_ci uint8_t window_update_queued; 2331cb0ef41Sopenharmony_ci /* extpri is a stream priority produced by nghttp2_extpri_to_uint8 2341cb0ef41Sopenharmony_ci used by RFC 9218 extensible priorities. */ 2351cb0ef41Sopenharmony_ci uint8_t extpri; 2361cb0ef41Sopenharmony_ci /* http_extpri is a stream priority received in HTTP request header 2371cb0ef41Sopenharmony_ci fields and produced by nghttp2_extpri_to_uint8. */ 2381cb0ef41Sopenharmony_ci uint8_t http_extpri; 2391cb0ef41Sopenharmony_ci}; 2401cb0ef41Sopenharmony_ci 2411cb0ef41Sopenharmony_civoid nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id, 2421cb0ef41Sopenharmony_ci uint8_t flags, nghttp2_stream_state initial_state, 2431cb0ef41Sopenharmony_ci int32_t weight, int32_t remote_initial_window_size, 2441cb0ef41Sopenharmony_ci int32_t local_initial_window_size, 2451cb0ef41Sopenharmony_ci void *stream_user_data, nghttp2_mem *mem); 2461cb0ef41Sopenharmony_ci 2471cb0ef41Sopenharmony_civoid nghttp2_stream_free(nghttp2_stream *stream); 2481cb0ef41Sopenharmony_ci 2491cb0ef41Sopenharmony_ci/* 2501cb0ef41Sopenharmony_ci * Disallow either further receptions or transmissions, or both. 2511cb0ef41Sopenharmony_ci * |flag| is bitwise OR of one or more of nghttp2_shut_flag. 2521cb0ef41Sopenharmony_ci */ 2531cb0ef41Sopenharmony_civoid nghttp2_stream_shutdown(nghttp2_stream *stream, nghttp2_shut_flag flag); 2541cb0ef41Sopenharmony_ci 2551cb0ef41Sopenharmony_ci/* 2561cb0ef41Sopenharmony_ci * Defer |stream->item|. We won't call this function in the situation 2571cb0ef41Sopenharmony_ci * where |stream->item| == NULL. The |flags| is bitwise OR of zero or 2581cb0ef41Sopenharmony_ci * more of NGHTTP2_STREAM_FLAG_DEFERRED_USER and 2591cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL. The |flags| indicates 2601cb0ef41Sopenharmony_ci * the reason of this action. 2611cb0ef41Sopenharmony_ci */ 2621cb0ef41Sopenharmony_civoid nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags); 2631cb0ef41Sopenharmony_ci 2641cb0ef41Sopenharmony_ci/* 2651cb0ef41Sopenharmony_ci * Put back deferred data in this stream to active state. The |flags| 2661cb0ef41Sopenharmony_ci * are one or more of bitwise OR of the following values: 2671cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_FLAG_DEFERRED_USER and 2681cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL and given masks are 2691cb0ef41Sopenharmony_ci * cleared if they are set. So even if this function is called, if 2701cb0ef41Sopenharmony_ci * one of flag is still set, data does not become active. 2711cb0ef41Sopenharmony_ci * 2721cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 2731cb0ef41Sopenharmony_ci * negative error codes: 2741cb0ef41Sopenharmony_ci * 2751cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 2761cb0ef41Sopenharmony_ci * Out of memory 2771cb0ef41Sopenharmony_ci */ 2781cb0ef41Sopenharmony_ciint nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags); 2791cb0ef41Sopenharmony_ci 2801cb0ef41Sopenharmony_ci/* 2811cb0ef41Sopenharmony_ci * Returns nonzero if item is deferred by whatever reason. 2821cb0ef41Sopenharmony_ci */ 2831cb0ef41Sopenharmony_ciint nghttp2_stream_check_deferred_item(nghttp2_stream *stream); 2841cb0ef41Sopenharmony_ci 2851cb0ef41Sopenharmony_ci/* 2861cb0ef41Sopenharmony_ci * Returns nonzero if item is deferred by flow control. 2871cb0ef41Sopenharmony_ci */ 2881cb0ef41Sopenharmony_ciint nghttp2_stream_check_deferred_by_flow_control(nghttp2_stream *stream); 2891cb0ef41Sopenharmony_ci 2901cb0ef41Sopenharmony_ci/* 2911cb0ef41Sopenharmony_ci * Updates the remote window size with the new value 2921cb0ef41Sopenharmony_ci * |new_initial_window_size|. The |old_initial_window_size| is used to 2931cb0ef41Sopenharmony_ci * calculate the current window size. 2941cb0ef41Sopenharmony_ci * 2951cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds or -1. The failure is due to 2961cb0ef41Sopenharmony_ci * overflow. 2971cb0ef41Sopenharmony_ci */ 2981cb0ef41Sopenharmony_ciint nghttp2_stream_update_remote_initial_window_size( 2991cb0ef41Sopenharmony_ci nghttp2_stream *stream, int32_t new_initial_window_size, 3001cb0ef41Sopenharmony_ci int32_t old_initial_window_size); 3011cb0ef41Sopenharmony_ci 3021cb0ef41Sopenharmony_ci/* 3031cb0ef41Sopenharmony_ci * Updates the local window size with the new value 3041cb0ef41Sopenharmony_ci * |new_initial_window_size|. The |old_initial_window_size| is used to 3051cb0ef41Sopenharmony_ci * calculate the current window size. 3061cb0ef41Sopenharmony_ci * 3071cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds or -1. The failure is due to 3081cb0ef41Sopenharmony_ci * overflow. 3091cb0ef41Sopenharmony_ci */ 3101cb0ef41Sopenharmony_ciint nghttp2_stream_update_local_initial_window_size( 3111cb0ef41Sopenharmony_ci nghttp2_stream *stream, int32_t new_initial_window_size, 3121cb0ef41Sopenharmony_ci int32_t old_initial_window_size); 3131cb0ef41Sopenharmony_ci 3141cb0ef41Sopenharmony_ci/* 3151cb0ef41Sopenharmony_ci * Call this function if promised stream |stream| is replied with 3161cb0ef41Sopenharmony_ci * HEADERS. This function makes the state of the |stream| to 3171cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_OPENED. 3181cb0ef41Sopenharmony_ci */ 3191cb0ef41Sopenharmony_civoid nghttp2_stream_promise_fulfilled(nghttp2_stream *stream); 3201cb0ef41Sopenharmony_ci 3211cb0ef41Sopenharmony_ci/* 3221cb0ef41Sopenharmony_ci * Returns nonzero if |target| is an ancestor of |stream|. 3231cb0ef41Sopenharmony_ci */ 3241cb0ef41Sopenharmony_ciint nghttp2_stream_dep_find_ancestor(nghttp2_stream *stream, 3251cb0ef41Sopenharmony_ci nghttp2_stream *target); 3261cb0ef41Sopenharmony_ci 3271cb0ef41Sopenharmony_ci/* 3281cb0ef41Sopenharmony_ci * Computes distributed weight of a stream of the |weight| under the 3291cb0ef41Sopenharmony_ci * |stream| if |stream| is removed from a dependency tree. 3301cb0ef41Sopenharmony_ci */ 3311cb0ef41Sopenharmony_ciint32_t nghttp2_stream_dep_distributed_weight(nghttp2_stream *stream, 3321cb0ef41Sopenharmony_ci int32_t weight); 3331cb0ef41Sopenharmony_ci 3341cb0ef41Sopenharmony_ci/* 3351cb0ef41Sopenharmony_ci * Makes the |stream| depend on the |dep_stream|. This dependency is 3361cb0ef41Sopenharmony_ci * exclusive. All existing direct descendants of |dep_stream| become 3371cb0ef41Sopenharmony_ci * the descendants of the |stream|. This function assumes 3381cb0ef41Sopenharmony_ci * |stream->item| is NULL. 3391cb0ef41Sopenharmony_ci * 3401cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3411cb0ef41Sopenharmony_ci * negative error codes: 3421cb0ef41Sopenharmony_ci * 3431cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 3441cb0ef41Sopenharmony_ci * Out of memory 3451cb0ef41Sopenharmony_ci */ 3461cb0ef41Sopenharmony_ciint nghttp2_stream_dep_insert(nghttp2_stream *dep_stream, 3471cb0ef41Sopenharmony_ci nghttp2_stream *stream); 3481cb0ef41Sopenharmony_ci 3491cb0ef41Sopenharmony_ci/* 3501cb0ef41Sopenharmony_ci * Makes the |stream| depend on the |dep_stream|. This dependency is 3511cb0ef41Sopenharmony_ci * not exclusive. This function assumes |stream->item| is NULL. 3521cb0ef41Sopenharmony_ci */ 3531cb0ef41Sopenharmony_civoid nghttp2_stream_dep_add(nghttp2_stream *dep_stream, nghttp2_stream *stream); 3541cb0ef41Sopenharmony_ci 3551cb0ef41Sopenharmony_ci/* 3561cb0ef41Sopenharmony_ci * Removes the |stream| from the current dependency tree. This 3571cb0ef41Sopenharmony_ci * function assumes |stream->item| is NULL. 3581cb0ef41Sopenharmony_ci */ 3591cb0ef41Sopenharmony_ciint nghttp2_stream_dep_remove(nghttp2_stream *stream); 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_ci/* 3621cb0ef41Sopenharmony_ci * Attaches |item| to |stream|. 3631cb0ef41Sopenharmony_ci * 3641cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3651cb0ef41Sopenharmony_ci * negative error codes: 3661cb0ef41Sopenharmony_ci * 3671cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 3681cb0ef41Sopenharmony_ci * Out of memory 3691cb0ef41Sopenharmony_ci */ 3701cb0ef41Sopenharmony_ciint nghttp2_stream_attach_item(nghttp2_stream *stream, 3711cb0ef41Sopenharmony_ci nghttp2_outbound_item *item); 3721cb0ef41Sopenharmony_ci 3731cb0ef41Sopenharmony_ci/* 3741cb0ef41Sopenharmony_ci * Detaches |stream->item|. This function does not free 3751cb0ef41Sopenharmony_ci * |stream->item|. The caller must free it. 3761cb0ef41Sopenharmony_ci */ 3771cb0ef41Sopenharmony_civoid nghttp2_stream_detach_item(nghttp2_stream *stream); 3781cb0ef41Sopenharmony_ci 3791cb0ef41Sopenharmony_ci/* 3801cb0ef41Sopenharmony_ci * Makes the |stream| depend on the |dep_stream|. This dependency is 3811cb0ef41Sopenharmony_ci * exclusive. 3821cb0ef41Sopenharmony_ci * 3831cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3841cb0ef41Sopenharmony_ci * negative error codes: 3851cb0ef41Sopenharmony_ci * 3861cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 3871cb0ef41Sopenharmony_ci * Out of memory 3881cb0ef41Sopenharmony_ci */ 3891cb0ef41Sopenharmony_ciint nghttp2_stream_dep_insert_subtree(nghttp2_stream *dep_stream, 3901cb0ef41Sopenharmony_ci nghttp2_stream *stream); 3911cb0ef41Sopenharmony_ci 3921cb0ef41Sopenharmony_ci/* 3931cb0ef41Sopenharmony_ci * Makes the |stream| depend on the |dep_stream|. This dependency is 3941cb0ef41Sopenharmony_ci * not exclusive. 3951cb0ef41Sopenharmony_ci * 3961cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3971cb0ef41Sopenharmony_ci * negative error codes: 3981cb0ef41Sopenharmony_ci * 3991cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4001cb0ef41Sopenharmony_ci * Out of memory 4011cb0ef41Sopenharmony_ci */ 4021cb0ef41Sopenharmony_ciint nghttp2_stream_dep_add_subtree(nghttp2_stream *dep_stream, 4031cb0ef41Sopenharmony_ci nghttp2_stream *stream); 4041cb0ef41Sopenharmony_ci 4051cb0ef41Sopenharmony_ci/* 4061cb0ef41Sopenharmony_ci * Removes subtree whose root stream is |stream|. The 4071cb0ef41Sopenharmony_ci * effective_weight of streams in removed subtree is not updated. 4081cb0ef41Sopenharmony_ci * 4091cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4101cb0ef41Sopenharmony_ci * negative error codes: 4111cb0ef41Sopenharmony_ci * 4121cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4131cb0ef41Sopenharmony_ci * Out of memory 4141cb0ef41Sopenharmony_ci */ 4151cb0ef41Sopenharmony_civoid nghttp2_stream_dep_remove_subtree(nghttp2_stream *stream); 4161cb0ef41Sopenharmony_ci 4171cb0ef41Sopenharmony_ci/* 4181cb0ef41Sopenharmony_ci * Returns nonzero if |stream| is in any dependency tree. 4191cb0ef41Sopenharmony_ci */ 4201cb0ef41Sopenharmony_ciint nghttp2_stream_in_dep_tree(nghttp2_stream *stream); 4211cb0ef41Sopenharmony_ci 4221cb0ef41Sopenharmony_ci/* 4231cb0ef41Sopenharmony_ci * Schedules transmission of |stream|'s item, assuming stream->item is 4241cb0ef41Sopenharmony_ci * attached, and stream->last_writelen was updated. 4251cb0ef41Sopenharmony_ci */ 4261cb0ef41Sopenharmony_civoid nghttp2_stream_reschedule(nghttp2_stream *stream); 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci/* 4291cb0ef41Sopenharmony_ci * Changes |stream|'s weight to |weight|. If |stream| is queued, it 4301cb0ef41Sopenharmony_ci * will be rescheduled based on new weight. 4311cb0ef41Sopenharmony_ci */ 4321cb0ef41Sopenharmony_civoid nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight); 4331cb0ef41Sopenharmony_ci 4341cb0ef41Sopenharmony_ci/* 4351cb0ef41Sopenharmony_ci * Returns a stream which has highest priority, updating 4361cb0ef41Sopenharmony_ci * descendant_last_cycle of selected stream's ancestors. 4371cb0ef41Sopenharmony_ci */ 4381cb0ef41Sopenharmony_cinghttp2_outbound_item * 4391cb0ef41Sopenharmony_cinghttp2_stream_next_outbound_item(nghttp2_stream *stream); 4401cb0ef41Sopenharmony_ci 4411cb0ef41Sopenharmony_ci#endif /* NGHTTP2_STREAM */ 442