19#include <nghttp2/nghttp2.h>
63 int arg,
const char *msg);
190 if (session && session->
ngh2) {
192 "proxy_session(%s): pool cleanup, state=%d, streams=%d",
217 if (transferred != -1)
225 "pass output failed to %pI (%s)",
249 "h2_proxy_sesssion(%s): raw_send %d bytes, flush=%d",
270 "h2_proxy_session(%s): recv FRAME[%s]",
276 switch (
frame->hd.type) {
306 "h2_proxy_session(%s): got interim HEADERS, "
307 "status=%d, will forward=%d",
320 if (
frame->settings.niv > 0) {
348 "h2_proxy_session(%s): sent FRAME[%s]",
361 const char *
n,
const char *v)
363 static const struct {
406 "h2_proxy_stream(%s-%d): got status %s",
418 "h2_proxy_stream(%s-%d): on_header %s: %s",
430 "h2_proxy_stream(%s-%d): got header %s: %s",
441 "h2_proxy_stream(%s-%d), header_out %s: %s",
506 "h2_proxy_stream(%s-%d), header_out after merging",
514 size_t len,
void *user_data)
524 "h2_proxy_session(%s): recv data chunk for "
525 "unknown stream %d, ignored",
526 session->
id, stream_id);
546 "h2_proxy_session(%s): stream=%d, response DATA %ld, %ld"
547 " total", session->
id, stream_id, (
long)
len,
551 "h2_proxy_session(%s): passing output on stream %d",
552 session->
id, stream->
id);
561 uint32_t error_code,
void *user_data)
567 "h2_proxy_session(%s): stream=%d, closed, err=%d",
568 session->
id, stream_id, error_code);
585 const char *
n = (
const char*)
namearg;
586 const char *v = (
const char*)
valuearg;
615 "h2_proxy_stream(NULL): data_read, stream %d not found",
635 "h2_proxy_stream(%s-%d): request body read",
674 "h2_proxy_stream(%d): request DATA %ld, %ld"
679 "h2_proxy_stream(%d): submit trailers", stream->
id);
688 "h2_proxy_stream(%s-%d): suspending",
701#ifdef H2_NG2_INVALID_HEADER_CB
711 "h2_proxy_session(%s-%d): denying stream with invalid header "
712 "'%s: %s'", session->
id, (
int)
frame->hd.stream_id,
725 unsigned char window_bits_connection,
726 unsigned char window_bits_stream,
737 p_conn->
data = session;
742 session->
conf = conf;
750 session->
done = done;
762#ifdef H2_NG2_INVALID_HEADER_CB
776 "setup session for %s", p_conn->
hostname);
792#if (!defined(WIN32) && !defined(NETWARE)) || defined(DOXYGEN)
844 scheme = (
strcmp(
puri.scheme,
"h2")?
"http" :
"https");
855 authority =
puri.hostname;
862 "authority=%s from uri.hostname=%s and uri.port=%d",
863 authority,
puri.hostname,
puri.port);
867 if (authority && strlen(authority)) {
938 provider.source.fd = 0;
939 provider.source.ptr =
NULL;
945 hd->nv,
hd->nvlen,
pp, stream);
948 "h2_proxy_session(%s): submit %s%s -> %d",
992 "h2_proxy_session(%s): feeding %ld bytes -> %ld",
993 session->
id, (
long)blen, (
long)
n);
1012 "h2_proxy_session(%s): fed %ld bytes of input to session",
1038 "h2_proxy_session(%s): unable to get conn socket",
1049 "h2_proxy_session(%s): read from conn", session->
id);
1050 if (
socket && save_timeout != -1) {
1063 "h2_proxy_session(%s): read error", session->
id);
1080 "process stream(%d): %s %s%s, original: %s",
1093 "h2_proxy_stream(%s-%d): resuming",
1094 session->
id, stream->
id);
1134 APLOGNO(03382)
"h2_proxy_stream(%s-%d): check input",
1135 session->
id, stream_id);
1155 const char *
err = msg;
1189 switch (session->
state) {
1203 "h2_proxy_session(%s): transit [%s] -- %s --> [%s]", session->
id,
1210 switch (session->
state) {
1228 switch (session->
state) {
1245 switch (session->
state) {
1262 switch (session->
state) {
1272 "h2_proxy_session(%s): conn error -> shutdown", session->
id);
1280 switch (session->
state) {
1289 "h2_proxy_session(%s): proto error -> shutdown", session->
id);
1297 switch (session->
state) {
1310 switch (session->
state) {
1348 switch (session->
state) {
1374 "h2_proxy_sesssion(%s): stream(%d) closed "
1375 "(touched=%d, error=%d)",
1411 if (session->
done) {
1416 switch (session->
state) {
1425 switch (session->
state) {
1437 switch (session->
state) {
1450 switch (session->
state) {
1462 switch (session->
state) {
1474 int arg,
const char *msg)
1518 "h2_proxy_session(%s): unknown event %d",
1530 "h2_proxy_session(%s): write, rv=%d", session->
id, rv);
1545 "h2_proxy_session(%s): process", session->
id);
1548 switch (session->
state) {
1609 "h2_proxy_session(%s): WAIT read, timeout=%fms",
1631 APLOGNO(03346)
"h2_proxy_session(%s): unknown state %d",
1671 "h2_proxy_session(%s): cancel %d streams",
1683 stream->
id <=
ctx->session->last_stream_id);
1706 "h2_proxy_session(%s): terminated, %d streams unfinished",
1733 "h2_proxy_session(%s): ping arrived, unblocking streams",
const char apr_size_t len
#define AP_SERVER_BASEVERSION
#define APLOG_USE_MODULE(foo)
#define ap_get_module_config(v, m)
request_rec int int apr_table_t const char * path
#define HTTP_VERSION_MAJOR(number)
#define HTTP_VERSION_MINOR(number)
#define ap_is_default_port(port, r)
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
apr_status_t ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
apr_port_t ap_get_server_port(const request_rec *r)
const char * ap_get_server_name(request_rec *r)
apr_socket_t * ap_get_conn_socket(conn_rec *c)
server_rec * ap_server_conf
const unsigned char * buf
int ap_map_http_request_error(apr_status_t rv, int status)
void ap_send_interim_response(request_rec *r, int send_headers)
void ap_set_content_type(request_rec *r, const char *ct)
const char * ap_get_status_line(int status)
apr_bucket * ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
const char apr_port_t port
#define ap_sock_disable_nagle(s)
#define APR_STATUS_IS_TIMEUP(s)
#define APR_STATUS_IS_EAGAIN(s)
#define APR_BUCKET_IS_METADATA(e)
#define APR_BRIGADE_INSERT_TAIL(b, e)
#define apr_bucket_split(e, point)
#define APR_BUCKET_BUFF_SIZE
#define APR_BRIGADE_EMPTY(b)
#define apr_bucket_delete(e)
#define APR_BUCKET_IS_EOS(e)
apr_brigade_flush void * ctx
#define APR_BRIGADE_FIRST(b)
#define apr_bucket_read(e, str, len, block)
const char apr_ssize_t int flags
#define APR_URI_UNP_OMITSITEPART
const char * ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url)
const char *(* ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *)
const char * ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str)
int ap_cstr_casecmp(const char *s1, const char *s2)
#define ap_strchr_c(s, c)
const char int apr_pool_t * pool
apr_sockaddr_t apr_sockaddr_t apr_sockaddr_t * source
apr_interval_time_t apr_pollcb_cb_t func
#define apr_pcalloc(p, size)
apr_int32_t apr_int32_t apr_int32_t err
#define apr_time_from_msec(msec)
apr_int64_t apr_interval_time_t
#define apr_time_from_sec(sec)
static int on_stream_close(nghttp2_session *ngh2, int32_t stream_id, uint32_t error_code, void *user_data)
static int send_loop(h2_proxy_session *session)
static apr_status_t submit_trailers(h2_proxy_stream *stream)
static void ping_reuse_session(h2_proxy_session *session)
static int ping_arrived_iter(void *udata, void *val)
static void ping_ev_frame_received(h2_proxy_session *session, const nghttp2_frame *frame)
static int log_header(void *ctx, const char *key, const char *value)
static apr_status_t feed_brigade(h2_proxy_session *session, apr_bucket_brigade *bb)
static int stream_response_data(nghttp2_session *ngh2, uint8_t flags, int32_t stream_id, const uint8_t *data, size_t len, void *user_data)
static void enter_ping_state(h2_proxy_session *session, h2_ping_state_t state)
int h2_proxy_session_is_reusable(h2_proxy_session *session)
static apr_status_t session_start(h2_proxy_session *session)
static void ev_data_read(h2_proxy_session *session, int arg, const char *msg)
static void ev_pre_close(h2_proxy_session *session, int arg, const char *msg)
static int cancel_iter(void *udata, void *val)
static void ev_proto_error(h2_proxy_session *session, int arg, const char *msg)
static apr_status_t submit_stream(h2_proxy_session *session, h2_proxy_stream *stream)
static void ping_new_session(h2_proxy_session *session, proxy_conn_rec *p_conn)
apr_status_t h2_proxy_session_submit(h2_proxy_session *session, const char *url, request_rec *r, int standalone)
static apr_status_t h2_proxy_session_read(h2_proxy_session *session, int block, apr_interval_time_t timeout)
static void set_ping_timeout(h2_proxy_session *session)
static void ev_stream_submitted(h2_proxy_session *session, int stream_id, const char *msg)
static void transit(h2_proxy_session *session, const char *action, h2_proxys_state nstate)
static void h2_proxy_stream_end_headers_out(h2_proxy_stream *stream)
static void ev_init(h2_proxy_session *session, int arg, const char *msg)
static apr_status_t open_stream(h2_proxy_session *session, const char *url, request_rec *r, int standalone, h2_proxy_stream **pstream)
static void ev_ngh2_done(h2_proxy_session *session, int arg, const char *msg)
static int on_header(nghttp2_session *ngh2, const nghttp2_frame *frame, const uint8_t *namearg, size_t nlen, const uint8_t *valuearg, size_t vlen, uint8_t flags, void *user_data)
static int is_waiting_for_backend(h2_proxy_session *session)
static void ev_stream_resumed(h2_proxy_session *session, int arg, const char *msg)
static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame, void *user_data)
static ssize_t raw_send(nghttp2_session *ngh2, const uint8_t *data, size_t length, int flags, void *user_data)
static int add_header(void *table, const char *n, const char *v)
static int is_accepting_streams(h2_proxy_session *session)
static apr_status_t check_suspended(h2_proxy_session *session)
static void ev_no_io(h2_proxy_session *session, int arg, const char *msg)
static void ev_remote_goaway(h2_proxy_session *session, int arg, const char *msg)
static int proxy_pass_brigade(apr_bucket_alloc_t *bucket_alloc, proxy_conn_rec *p_conn, conn_rec *origin, apr_bucket_brigade *bb, int flush)
apr_status_t h2_proxy_session_process(h2_proxy_session *session)
static int before_frame_send(nghttp2_session *ngh2, const nghttp2_frame *frame, void *user_data)
static apr_status_t h2_proxy_stream_add_header_out(h2_proxy_stream *stream, const char *n, apr_size_t nlen, const char *v, apr_size_t vlen)
static void stream_resume(h2_proxy_stream *stream)
void h2_proxy_session_cancel_all(h2_proxy_session *session)
static void ev_local_goaway(h2_proxy_session *session, int arg, const char *msg)
static void ev_stream_done(h2_proxy_session *session, int stream_id, const char *msg)
h2_proxy_session * h2_proxy_session_setup(const char *id, proxy_conn_rec *p_conn, proxy_server_conf *conf, int h2_front, unsigned char window_bits_connection, unsigned char window_bits_stream, h2_proxy_request_done *done)
static void process_proxy_header(apr_table_t *headers, h2_proxy_stream *stream, const char *n, const char *v)
static const char * StateNames[]
static void ev_conn_timeout(h2_proxy_session *session, int arg, const char *msg)
static void unset_ping_timeout(h2_proxy_session *session)
static const char * state_name(h2_proxys_state state)
static void ev_conn_error(h2_proxy_session *session, int arg, const char *msg)
static ssize_t stream_request_data(nghttp2_session *ngh2, int32_t stream_id, uint8_t *buf, size_t length, uint32_t *data_flags, nghttp2_data_source *source, void *user_data)
static apr_status_t session_shutdown(h2_proxy_session *session, int reason, const char *msg)
static int done_iter(void *udata, void *val)
static void dispatch_event(h2_proxy_session *session, h2_proxys_event_t ev, int arg, const char *msg)
static void ping_arrived(h2_proxy_session *session)
void h2_proxy_session_cleanup(h2_proxy_session *session, h2_proxy_request_done *done)
static apr_status_t proxy_session_pre_close(void *theconn)
@ H2_PROXYS_ST_LOCAL_SHUTDOWN
@ H2_PROXYS_ST_REMOTE_SHUTDOWN
void h2_proxy_request_done(h2_proxy_session *s, request_rec *r, apr_status_t status, int touched, int error_code)
@ H2_PROXYS_EV_CONN_TIMEOUT
@ H2_PROXYS_EV_STREAM_RESUMED
@ H2_PROXYS_EV_STREAM_DONE
@ H2_PROXYS_EV_PROTO_ERROR
@ H2_PROXYS_EV_CONN_ERROR
@ H2_PROXYS_EV_REMOTE_GOAWAY
@ H2_PROXYS_EV_LOCAL_GOAWAY
@ H2_PROXYS_EV_STREAM_SUBMITTED
int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid)
int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx)
apr_status_t h2_proxy_req_make(h2_proxy_request *req, apr_pool_t *pool, const char *method, const char *scheme, const char *authority, const char *path, apr_table_t *headers)
h2_proxy_ngheader * h2_proxy_util_nghd_make(apr_pool_t *p, apr_table_t *headers)
int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id)
void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx)
h2_proxy_request * h2_proxy_req_create(int id, apr_pool_t *pool)
h2_proxy_ngheader * h2_proxy_util_nghd_make_req(apr_pool_t *p, const h2_proxy_request *req)
void * h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id)
h2_proxy_ihash_t * h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int)
void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih)
void h2_proxy_util_camel_case_header(char *s, size_t len)
size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih)
void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val)
h2_proxy_iqueue * h2_proxy_iq_create(apr_pool_t *pool, int capacity)
int h2_proxy_res_ignore_header(const char *name, size_t len)
const char * h2_proxy_link_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *real_backend_uri, const char *proxy_server_uri, const char *s)
int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih)
static apr_status_t age(proxy_balancer *balancer, server_rec *s)
Proxy Extension Module for Apache.
Multi-Processing Modules functions.
h2_proxy_session * session
h2_proxy_request_done * done
Structure to store things which are per connection.
struct ap_filter_t * input_filters
struct ap_filter_t * output_filters
struct apr_bucket_alloc_t * bucket_alloc
h2_proxy_request_done * done
apr_interval_time_t wait_timeout
apr_bucket_brigade * output
apr_bucket_brigade * input
unsigned char window_bits_stream
h2_ping_state_t ping_state
apr_time_t last_frame_received
apr_size_t remote_max_concurrent
struct h2_proxy_ihash_t * streams
unsigned char window_bits_connection
struct h2_proxy_iqueue * suspended
apr_bucket_brigade * output
h2_proxy_session * session
const char * real_server_uri
h2_proxy_stream_state_t state
unsigned int headers_ended
unsigned int waiting_on_ping
unsigned int waiting_on_100
apr_bucket_brigade * input
const char * p_server_uri
unsigned int preserve_host
unsigned int add_forwarded_headers
enum proxy_server_conf::@32 viaopt
unsigned int ping_timeout_set
apr_interval_time_t ping_timeout
A structure that represents the current request.
apr_table_t * trailers_in
struct ap_filter_t * output_filters
struct ap_filter_t * input_filters
struct ap_conf_vector_t * per_dir_config
apr_table_t * trailers_out
apr_table_t * headers_out
h2_proxy_session * session
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t)
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray