#ifndef NGHTTP2_STREAM_H
#define NGHTTP2_STREAM_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <nghttp2/nghttp2.h>
#include "nghttp2_outbound_item.h"
#include "nghttp2_map.h"
#include "nghttp2_pq.h"
#include "nghttp2_int.h"
typedef enum {
NGHTTP2_STREAM_INITIAL,
NGHTTP2_STREAM_OPENING,
NGHTTP2_STREAM_OPENED,
NGHTTP2_STREAM_CLOSING,
NGHTTP2_STREAM_RESERVED,
NGHTTP2_STREAM_IDLE
} nghttp2_stream_state;
typedef enum {
NGHTTP2_SHUT_NONE = 0,
NGHTTP2_SHUT_RD = 0x01,
NGHTTP2_SHUT_WR = 0x02,
NGHTTP2_SHUT_RDWR = NGHTTP2_SHUT_RD | NGHTTP2_SHUT_WR
} nghttp2_shut_flag;
typedef enum {
NGHTTP2_STREAM_FLAG_NONE = 0,
NGHTTP2_STREAM_FLAG_PUSH = 0x01,
NGHTTP2_STREAM_FLAG_CLOSED = 0x02,
NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL = 0x04,
NGHTTP2_STREAM_FLAG_DEFERRED_USER = 0x08,
NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c,
NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES = 0x20,
NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 0x40,
} nghttp2_stream_flag;
typedef enum {
NGHTTP2_HTTP_FLAG_NONE = 0,
NGHTTP2_HTTP_FLAG__AUTHORITY = 1,
NGHTTP2_HTTP_FLAG__PATH = 1 << 1,
NGHTTP2_HTTP_FLAG__METHOD = 1 << 2,
NGHTTP2_HTTP_FLAG__SCHEME = 1 << 3,
NGHTTP2_HTTP_FLAG_HOST = 1 << 4,
NGHTTP2_HTTP_FLAG__STATUS = 1 << 5,
NGHTTP2_HTTP_FLAG_REQ_HEADERS = NGHTTP2_HTTP_FLAG__METHOD |
NGHTTP2_HTTP_FLAG__PATH |
NGHTTP2_HTTP_FLAG__SCHEME,
NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED = 1 << 6,
NGHTTP2_HTTP_FLAG_METH_CONNECT = 1 << 7,
NGHTTP2_HTTP_FLAG_METH_HEAD = 1 << 8,
NGHTTP2_HTTP_FLAG_METH_OPTIONS = 1 << 9,
NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND = 1 << 10,
NGHTTP2_HTTP_FLAG_METH_ALL =
NGHTTP2_HTTP_FLAG_METH_CONNECT | NGHTTP2_HTTP_FLAG_METH_HEAD |
NGHTTP2_HTTP_FLAG_METH_OPTIONS | NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND,
NGHTTP2_HTTP_FLAG_PATH_REGULAR = 1 << 11,
NGHTTP2_HTTP_FLAG_PATH_ASTERISK = 1 << 12,
NGHTTP2_HTTP_FLAG_SCHEME_HTTP = 1 << 13,
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14,
NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15,
NGHTTP2_HTTP_FLAG_PRIORITY = 1 << 16,
NGHTTP2_HTTP_FLAG_BAD_PRIORITY = 1 << 17,
} nghttp2_http_flag;
struct nghttp2_stream {
nghttp2_stream_state state;
nghttp2_pq_entry pq_entry;
int64_t content_length;
int64_t recv_content_length;
uint64_t cycle;
uint64_t seq;
nghttp2_stream *closed_next;
void *stream_user_data;
nghttp2_outbound_item *item;
size_t last_writelen;
int32_t stream_id;
int32_t remote_window_size;
int32_t recv_window_size;
int32_t consumed_size;
int32_t recv_reduction;
int32_t local_window_size;
uint32_t pending_penalty;
int16_t status_code;
uint32_t http_flags;
uint8_t flags;
uint8_t shut_flags;
uint8_t queued;
uint8_t window_update_queued;
uint8_t extpri;
uint8_t http_extpri;
};
void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
uint8_t flags, nghttp2_stream_state initial_state,
int32_t remote_initial_window_size,
int32_t local_initial_window_size,
void *stream_user_data);
void nghttp2_stream_free(nghttp2_stream *stream);
void nghttp2_stream_shutdown(nghttp2_stream *stream, nghttp2_shut_flag flag);
void nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags);
void nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags);
int nghttp2_stream_check_deferred_item(nghttp2_stream *stream);
int nghttp2_stream_check_deferred_by_flow_control(nghttp2_stream *stream);
int nghttp2_stream_update_remote_initial_window_size(
nghttp2_stream *stream, int32_t new_initial_window_size,
int32_t old_initial_window_size);
int nghttp2_stream_update_local_initial_window_size(
nghttp2_stream *stream, int32_t new_initial_window_size,
int32_t old_initial_window_size);
void nghttp2_stream_promise_fulfilled(nghttp2_stream *stream);
void nghttp2_stream_attach_item(nghttp2_stream *stream,
nghttp2_outbound_item *item);
void nghttp2_stream_detach_item(nghttp2_stream *stream);
#endif