29#include <nghttp2/nghttp2.h>
43 if (!(
n & 0xffff0000u)) {
47 if (!(
n & 0xff000000u)) {
51 if (!(
n & 0xf0000000u)) {
55 if (!(
n & 0xc0000000u)) {
59 if (!(
n & 0x80000000u)) {
76 return (
unsigned int)(*((
int*)
key));
134 int id = *((
int*)((
char *)
val + ih->
ioff));
154 if (
ctx->len <
ctx->max) {
171 for (
i = 0;
i <
ctx.len; ++
i) {
187 if (
ctx->len <
ctx->max) {
204 for (
i = 0;
i <
ctx.len; ++
i) {
234 return q->
nelts == 0;
299 while (
i != q->
head) {
383#define H2_HD_MATCH_LIT_CS(l, name) \
384 ((strlen(name) == sizeof(l) - 1) && !apr_strnatcasecmp(l, name))
404#define NV_ADD_LIT_CS(nv, k, v) add_header(nv, k, sizeof(k) - 1, v, strlen(v))
405#define NV_ADD_CS_CS(nv, k, v) add_header(nv, k, strlen(k), v, strlen(v))
480#define H2_DEF_LITERAL(n) { (n), (sizeof(n)-1) }
481#define H2_LIT_ARGS(a) (a),H2_ALEN(a)
525 for (
i = 0;
i <
len; ++
i) {
527 if (
s[
i] >=
'a' &&
s[
i] <=
'z') {
533 else if (
s[
i] ==
'-') {
544#define H2_HD_MATCH_LIT(l, name, nlen) \
545 ((nlen == sizeof(l) - 1) && !apr_strnatcasecmp(l, name))
585 const char *scheme,
const char *authority,
621 const char *
method,
const char *scheme,
622 const char *authority,
const char *
path,
656 size_t s_len =
sizeof(scratch)/
sizeof(scratch[0]);
658 switch (
frame->hd.type) {
661 "DATA[length=%d, flags=%d, stream=%d, padlen=%d]",
663 frame->hd.stream_id, (
int)
frame->data.padlen);
667 "HEADERS[length=%d, hend=%d, stream=%d, eos=%d]",
668 (
int)
frame->hd.length,
675 "PRIORITY[length=%d, flags=%d, stream=%d]",
676 (
int)
frame->hd.length,
681 "RST_STREAM[length=%d, flags=%d, stream=%d]",
682 (
int)
frame->hd.length,
688 "SETTINGS[ack=1, stream=%d]",
689 frame->hd.stream_id);
692 "SETTINGS[length=%d, stream=%d]",
697 "PUSH_PROMISE[length=%d, hend=%d, stream=%d]",
698 (
int)
frame->hd.length,
700 frame->hd.stream_id);
704 "PING[length=%d, ack=%d, stream=%d]",
705 (
int)
frame->hd.length,
707 frame->hd.stream_id);
715 "last_stream=%d]",
frame->goaway.error_code,
716 scratch,
frame->goaway.last_stream_id);
720 "WINDOW_UPDATE[stream=%d, incr=%d]",
722 frame->window_update.window_size_increment);
726 "type=%d[length=%d, flags=%d, stream=%d]",
814 && (((
c =
ctx->s[
ctx->i]) ==
' ') || (
c ==
'\t'))) {
817 return (
ctx->i <
ctx->slen);
823 for (j =
ctx->i; j <
ctx->slen; ++j) {
824 if (
ctx->s[j] ==
c) {
871 ctx->link_start =
ctx->link_end = 0;
952 if (
ctx->link_start <
ctx->link_end) {
959 link_len =
ctx->link_end -
ctx->link_start;
967 buffer_len =
ctx->psu_len;
971 "link_reverse_map uri too long, skipped: %s",
ctx->s);
981 link_len -=
ctx->rbu_len;
984 buffer_len =
ctx->psu_len + link_len;
985 buffer[buffer_len] =
'\0';
994 ctx->su_len = (
int)strlen(
ctx->server_uri);
1045 const char *real_backend_uri,
1058 ctx.real_backend_uri = real_backend_uri;
1059 ctx.rbu_len = (
int)strlen(
ctx.real_backend_uri);
1061 ctx.psu_len = (
int)strlen(
ctx.p_server_uri);
1074 "link_reverse_map %s --> %s",
s,
ctx.s);
1114 for (
i = 0;
i <
fifo->count; ++
i) {
1123 int capacity,
int as_set)
1153 fifo->nelems = capacity;
1200 return fifo->nelems;
1205 if (
fifo->count == 0) {
1209 while (
fifo->count == 0) {
1210 if (
fifo->aborted) {
1223 if (
fifo->aborted) {
1233 else if (
fifo->count ==
fifo->nelems) {
1235 while (
fifo->count ==
fifo->nelems) {
1236 if (
fifo->aborted) {
1252 if (
fifo->count == 1) {
1277 if (
fifo->count > 0) {
1279 if (
fifo->count+1 ==
fifo->nelems) {
1290 if (
fifo->aborted) {
1323 if (
fifo->aborted) {
1332 for (
i = 0;
i <
fifo->count; ++
i) {
const char apr_size_t len
APR general purpose library routines.
APR Condition Variable Routines.
APR Thread Mutex Routines.
#define APLOG_USE_MODULE(foo)
request_rec int int apr_table_t const char * path
char * ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r)
apr_file_t apr_off_t start
apr_brigade_flush void * ctx
const char apr_int32_t apr_uint32_t * nv
const char * ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url)
int ap_find_token(apr_pool_t *p, const char *line, const char *tok)
apr_uint32_t apr_uint32_t cmp
const char int apr_pool_t * pool
apr_vformatter_buff_t * c
apr_uint32_t apr_pool_t apr_uint32_t apr_pollset_method_e method
#define apr_pcalloc(p, size)
apr_size_t apr_size_t max
apr_status_t h2_proxy_fifo_try_push(h2_proxy_fifo *fifo, void *elem)
apr_status_t h2_proxy_fifo_try_pull(h2_proxy_fifo *fifo, void **pelem)
int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid)
static int add_header(h2_proxy_ngheader *ngh, const char *key, size_t key_len, const char *value, size_t val_len)
int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx)
static int iq_bubble_up(h2_proxy_iqueue *q, int i, int top, h2_proxy_iq_cmp *cmp, void *ctx)
void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val)
static void iq_grow(h2_proxy_iqueue *q, int nlen)
apr_status_t h2_proxy_fifo_remove(h2_proxy_fifo *fifo, void *elem)
static int collect_iter(void *x, void *val)
static apr_status_t check_not_empty(h2_proxy_fifo *fifo, int block)
apr_status_t h2_proxy_fifo_set_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
#define H2_DEF_LITERAL(n)
static int skip_ws(link_ctx *ctx)
static int read_link(link_ctx *ctx)
#define H2_HD_MATCH_LIT(l, name, nlen)
static void map_link(link_ctx *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)
void h2_proxy_iq_clear(h2_proxy_iqueue *q)
static int read_chr(link_ctx *ctx, char c)
int h2_proxy_iq_shift(h2_proxy_iqueue *q)
static literal IgnoredRequestHeaders[]
h2_proxy_ngheader * h2_proxy_util_nghd_make(apr_pool_t *p, apr_table_t *headers)
int h2_proxy_fifo_count(h2_proxy_fifo *fifo)
apr_status_t h2_proxy_fifo_pull(h2_proxy_fifo *fifo, void **pelem)
static h2_proxy_request * h2_proxy_req_createn(int id, apr_pool_t *pool, const char *method, const char *scheme, const char *authority, const char *path, apr_table_t *header)
static apr_status_t fifo_destroy(void *data)
unsigned char h2_proxy_log2(int n)
int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
static int h2_proxy_req_ignore_header(const char *name, size_t len)
apr_status_t h2_proxy_fifo_interrupt(h2_proxy_fifo *fifo)
static int attr_char(char c)
static literal IgnoredProxyRespHds[]
void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id)
int h2_proxy_fifo_capacity(h2_proxy_fifo *fifo)
static apr_status_t fifo_pull(h2_proxy_fifo *fifo, void **pelem, int block)
static int count_header(void *ctx, const char *key, const char *value)
static int iq_bubble_down(h2_proxy_iqueue *q, int i, int bottom, h2_proxy_iq_cmp *cmp, void *ctx)
static int ignore_header(const literal *lits, size_t llen, const char *name, size_t nlen)
size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max)
void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx)
int h2_proxy_iq_empty(h2_proxy_iqueue *q)
h2_proxy_request * h2_proxy_req_create(int id, apr_pool_t *pool)
static int skip_pvalue(link_ctx *ctx)
size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max)
h2_proxy_ngheader * h2_proxy_util_nghd_make_req(apr_pool_t *p, const h2_proxy_request *req)
static int ihash_iter(void *ctx, const void *key, apr_ssize_t klen, const void *val)
static int nth_index(h2_proxy_fifo *fifo, int n)
static size_t subst_str(link_ctx *ctx, int start, int end, const char *ns)
static int read_sep(link_ctx *ctx)
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)
static apr_status_t create_int(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity, int as_set)
static int index_of(h2_proxy_fifo *fifo, void *elem)
static apr_status_t fifo_push(h2_proxy_fifo *fifo, void *elem, int block)
static int find_chr(link_ctx *ctx, char c, int *pidx)
static unsigned int ihash(const char *key, apr_ssize_t *klen)
void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih)
static int h2_util_ignore_header(const char *name)
void h2_proxy_util_camel_case_header(char *s, size_t len)
int h2_proxy_iq_count(h2_proxy_iqueue *q)
apr_status_t h2_proxy_fifo_term(h2_proxy_fifo *fifo)
static apr_status_t h2_headers_add_h1(apr_table_t *headers, apr_pool_t *pool, const char *name, size_t nlen, const char *value, size_t vlen)
size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih)
void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val)
void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx)
static void * pull_head(h2_proxy_fifo *fifo)
static int skip_param(link_ctx *ctx)
#define H2_HD_MATCH_LIT_CS(l, name)
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)
static int skip_ptoken(link_ctx *ctx)
static int icollect_iter(void *x, void *val)
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)
apr_status_t h2_proxy_fifo_push(h2_proxy_fifo *fifo, void *elem)
static int skip_pname(link_ctx *ctx)
static int ptoken_char(char c)
static int add_table_header(void *ctx, const char *key, const char *value)
static int set_h1_header(void *ctx, const char *key, const char *value)
int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih)
#define NV_ADD_LIT_CS(nv, k, v)
static int skip_qstring(link_ctx *ctx)
apr_status_t h2_proxy_fifo_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
static void iq_swap(h2_proxy_iqueue *q, int i, int j)
int h2_proxy_iq_cmp(int i1, int i2, void *ctx)
int h2_proxy_ihash_iter_t(void *ctx, void *val)
Proxy Extension Module for Apache.
apr_thread_mutex_t * lock
apr_thread_cond_t * not_empty
apr_thread_cond_t * not_full
h2_proxy_ihash_iter_t * iter
const char * real_backend_uri
const char * p_server_uri
A structure that represents the current request.
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray