Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
h2_util.c File Reference
#include <assert.h>
#include <apr_strings.h>
#include <apr_thread_mutex.h>
#include <apr_thread_cond.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
#include <http_protocol.h>
#include <http_request.h>
#include <nghttp2/nghttp2.h>
#include "h2.h"
#include "h2_headers.h"
#include "h2_util.h"

Go to the source code of this file.

Classes

struct  h2_ihash_t
 
struct  iter_ctx
 
struct  collect_ctx
 
struct  h2_fifo
 
struct  h2_ififo
 
struct  table_bytes_ctx
 
struct  ngh_ctx
 
struct  literal
 

Macros

#define N6   (unsigned int)-1
 
#define BASE64URL_CHAR(x)   BASE64URL_CHARS[ (unsigned int)(x) & 0x3fu ]
 
#define H2_DEF_LITERAL(n)   { (n), (sizeof(n)-1) }
 
#define H2_LIT_ARGS(a)   (a),H2_ALEN(a)
 

Typedefs

typedef struct ngh_ctx ngh_ctx
 

Functions

unsigned char h2_log2 (int n)
 
size_t h2_util_hex_dump (char *buffer, size_t maxlen, const char *data, size_t datalen)
 
void h2_util_camel_case_header (char *s, size_t len)
 
apr_size_t h2_util_base64url_decode (const char **decoded, const char *encoded, apr_pool_t *pool)
 
const charh2_util_base64url_encode (const char *data, apr_size_t dlen, apr_pool_t *pool)
 
static unsigned int ihash (const char *key, apr_ssize_t *klen)
 
h2_ihash_th2_ihash_create (apr_pool_t *pool, size_t offset_of_int)
 
unsigned int h2_ihash_count (h2_ihash_t *ih)
 
int h2_ihash_empty (h2_ihash_t *ih)
 
void * h2_ihash_get (h2_ihash_t *ih, int id)
 
static int ihash_iter (void *ctx, const void *key, apr_ssize_t klen, const void *val)
 
int h2_ihash_iter (h2_ihash_t *ih, h2_ihash_iter_t *fn, void *ctx)
 
void h2_ihash_add (h2_ihash_t *ih, void *val)
 
void h2_ihash_remove (h2_ihash_t *ih, int id)
 
void h2_ihash_remove_val (h2_ihash_t *ih, void *val)
 
void h2_ihash_clear (h2_ihash_t *ih)
 
static int collect_iter (void *x, void *val)
 
size_t h2_ihash_shift (h2_ihash_t *ih, void **buffer, size_t max)
 
static void iq_grow (h2_iqueue *q, int nlen)
 
static void iq_swap (h2_iqueue *q, int i, int j)
 
static int iq_bubble_up (h2_iqueue *q, int i, int top, h2_iq_cmp *cmp, void *ctx)
 
static int iq_bubble_down (h2_iqueue *q, int i, int bottom, h2_iq_cmp *cmp, void *ctx)
 
h2_iqueueh2_iq_create (apr_pool_t *pool, int capacity)
 
int h2_iq_empty (h2_iqueue *q)
 
int h2_iq_count (h2_iqueue *q)
 
int h2_iq_add (h2_iqueue *q, int sid, h2_iq_cmp *cmp, void *ctx)
 
int h2_iq_append (h2_iqueue *q, int sid)
 
int h2_iq_remove (h2_iqueue *q, int sid)
 
void h2_iq_clear (h2_iqueue *q)
 
void h2_iq_sort (h2_iqueue *q, h2_iq_cmp *cmp, void *ctx)
 
int h2_iq_shift (h2_iqueue *q)
 
size_t h2_iq_mshift (h2_iqueue *q, int *pint, size_t max)
 
int h2_iq_contains (h2_iqueue *q, int sid)
 
static apr_status_t fifo_destroy (void *data)
 
static int index_of (h2_fifo *fifo, void *elem)
 
static apr_status_t create_int (h2_fifo **pfifo, apr_pool_t *pool, int capacity, int as_set)
 
apr_status_t h2_fifo_create (h2_fifo **pfifo, apr_pool_t *pool, int capacity)
 
apr_status_t h2_fifo_set_create (h2_fifo **pfifo, apr_pool_t *pool, int capacity)
 
apr_status_t h2_fifo_term (h2_fifo *fifo)
 
int h2_fifo_count (h2_fifo *fifo)
 
static apr_status_t check_not_empty (h2_fifo *fifo, int block)
 
static apr_status_t fifo_push_int (h2_fifo *fifo, void *elem, int block)
 
static apr_status_t fifo_push (h2_fifo *fifo, void *elem, int block)
 
apr_status_t h2_fifo_push (h2_fifo *fifo, void *elem)
 
apr_status_t h2_fifo_try_push (h2_fifo *fifo, void *elem)
 
static apr_status_t pull_head (h2_fifo *fifo, void **pelem, int block)
 
static apr_status_t fifo_pull (h2_fifo *fifo, void **pelem, int block)
 
apr_status_t h2_fifo_pull (h2_fifo *fifo, void **pelem)
 
apr_status_t h2_fifo_try_pull (h2_fifo *fifo, void **pelem)
 
static apr_status_t fifo_peek (h2_fifo *fifo, h2_fifo_peek_fn *fn, void *ctx, int block)
 
apr_status_t h2_fifo_peek (h2_fifo *fifo, h2_fifo_peek_fn *fn, void *ctx)
 
apr_status_t h2_fifo_try_peek (h2_fifo *fifo, h2_fifo_peek_fn *fn, void *ctx)
 
apr_status_t h2_fifo_remove (h2_fifo *fifo, void *elem)
 
static int inth_index (h2_ififo *fifo, int n)
 
static apr_status_t ififo_destroy (void *data)
 
static int iindex_of (h2_ififo *fifo, int id)
 
static apr_status_t icreate_int (h2_ififo **pfifo, apr_pool_t *pool, int capacity, int as_set)
 
apr_status_t h2_ififo_create (h2_ififo **pfifo, apr_pool_t *pool, int capacity)
 
apr_status_t h2_ififo_set_create (h2_ififo **pfifo, apr_pool_t *pool, int capacity)
 
apr_status_t h2_ififo_term (h2_ififo *fifo)
 
int h2_ififo_count (h2_ififo *fifo)
 
static apr_status_t icheck_not_empty (h2_ififo *fifo, int block)
 
static apr_status_t ififo_push_int (h2_ififo *fifo, int id, int block)
 
static apr_status_t ififo_push (h2_ififo *fifo, int id, int block)
 
apr_status_t h2_ififo_push (h2_ififo *fifo, int id)
 
apr_status_t h2_ififo_try_push (h2_ififo *fifo, int id)
 
static apr_status_t ipull_head (h2_ififo *fifo, int *pi, int block)
 
static apr_status_t ififo_pull (h2_ififo *fifo, int *pi, int block)
 
apr_status_t h2_ififo_pull (h2_ififo *fifo, int *pi)
 
apr_status_t h2_ififo_try_pull (h2_ififo *fifo, int *pi)
 
static apr_status_t ififo_peek (h2_ififo *fifo, h2_ififo_peek_fn *fn, void *ctx, int block)
 
apr_status_t h2_ififo_peek (h2_ififo *fifo, h2_ififo_peek_fn *fn, void *ctx)
 
apr_status_t h2_ififo_try_peek (h2_ififo *fifo, h2_ififo_peek_fn *fn, void *ctx)
 
static apr_status_t ififo_remove (h2_ififo *fifo, int id)
 
apr_status_t h2_ififo_remove (h2_ififo *fifo, int id)
 
static int count_bytes (void *x, const char *key, const char *value)
 
apr_size_t h2_util_table_bytes (apr_table_t *t, apr_size_t pair_extra)
 
static void fit_bucket_into (apr_bucket *b, apr_off_t *plen)
 
apr_status_t h2_brigade_concat_length (apr_bucket_brigade *dest, apr_bucket_brigade *src, apr_off_t length)
 
apr_status_t h2_brigade_copy_length (apr_bucket_brigade *dest, apr_bucket_brigade *src, apr_off_t length)
 
apr_size_t h2_util_bucket_print (char *buffer, apr_size_t bmax, apr_bucket *b, const char *sep)
 
apr_size_t h2_util_bb_print (char *buffer, apr_size_t bmax, const char *tag, const char *sep, apr_bucket_brigade *bb)
 
apr_status_t h2_append_brigade (apr_bucket_brigade *to, apr_bucket_brigade *from, apr_off_t *plen, int *peos, h2_bucket_gate *should_append)
 
apr_off_t h2_brigade_mem_size (apr_bucket_brigade *bb)
 
static int count_header (void *ctx, const char *key, const char *value)
 
static const charinv_field_name_chr (const char *token)
 
static const charinv_field_value_chr (const char *token)
 
static void strip_field_value_ws (nghttp2_nv *nv)
 
static int add_header (ngh_ctx *ctx, const char *key, const char *value)
 
static int add_table_header (void *ctx, const char *key, const char *value)
 
static apr_status_t ngheader_create (h2_ngheader **ph, apr_pool_t *p, int unsafe, size_t key_count, const char *keys[], const char *values[], apr_table_t *headers)
 
static int is_unsafe (h2_headers *h)
 
apr_status_t h2_res_create_ngtrailer (h2_ngheader **ph, apr_pool_t *p, h2_headers *headers)
 
apr_status_t h2_res_create_ngheader (h2_ngheader **ph, apr_pool_t *p, h2_headers *headers)
 
apr_status_t h2_req_create_ngheader (h2_ngheader **ph, apr_pool_t *p, const struct h2_request *req)
 
static int contains_name (const literal *lits, size_t llen, nghttp2_nv *nv)
 
int h2_util_ignore_resp_header (const char *name)
 
static int h2_req_ignore_header (nghttp2_nv *nv)
 
int h2_ignore_req_trailer (const char *name, size_t len)
 
int h2_ignore_resp_trailer (const char *name, size_t len)
 
static apr_status_t req_add_header (apr_table_t *headers, apr_pool_t *pool, nghttp2_nv *nv, size_t max_field_len, int *pwas_added)
 
apr_status_t h2_req_add_header (apr_table_t *headers, apr_pool_t *pool, const char *name, size_t nlen, const char *value, size_t vlen, size_t max_field_len, int *pwas_added)
 
int h2_util_frame_print (const nghttp2_frame *frame, char *buffer, size_t maxlen)
 
int h2_push_policy_determine (apr_table_t *headers, apr_pool_t *p, int push_enabled)
 
void h2_util_drain_pipe (apr_file_t *pipe)
 
apr_status_t h2_util_wait_on_pipe (apr_file_t *pipe)
 

Variables

static const unsigned int BASE64URL_UINT6 []
 
static const unsigned char BASE64URL_CHARS []
 
static literal IgnoredRequestHeaders []
 
static literal IgnoredRequestTrailers []
 
static literal IgnoredResponseHeaders []
 
static literal IgnoredResponseTrailers []
 

Macro Definition Documentation

◆ BASE64URL_CHAR

#define BASE64URL_CHAR (   x)    BASE64URL_CHARS[ (unsigned int)(x) & 0x3fu ]

Definition at line 131 of file h2_util.c.

◆ H2_DEF_LITERAL

#define H2_DEF_LITERAL (   n)    { (n), (sizeof(n)-1) }

Definition at line 1601 of file h2_util.c.

◆ H2_LIT_ARGS

#define H2_LIT_ARGS (   a)    (a),H2_ALEN(a)

Definition at line 1602 of file h2_util.c.

◆ N6

#define N6   (unsigned int)-1

Definition at line 100 of file h2_util.c.

Typedef Documentation

◆ ngh_ctx

Function Documentation

◆ add_header()

static int add_header ( ngh_ctx ctx,
const char key,
const char value 
)
static

Definition at line 1434 of file h2_util.c.

◆ add_table_header()

static int add_table_header ( void *  ctx,
const char key,
const char value 
)
static

Definition at line 1464 of file h2_util.c.

◆ check_not_empty()

static apr_status_t check_not_empty ( h2_fifo fifo,
int  block 
)
static

Definition at line 634 of file h2_util.c.

◆ collect_iter()

static int collect_iter ( void *  x,
void *  val 
)
static

Definition at line 297 of file h2_util.c.

◆ contains_name()

static int contains_name ( const literal lits,
size_t  llen,
nghttp2_nv nv 
)
static

Definition at line 1645 of file h2_util.c.

◆ count_bytes()

static int count_bytes ( void *  x,
const char key,
const char value 
)
static

Definition at line 1145 of file h2_util.c.

◆ count_header()

static int count_header ( void *  ctx,
const char key,
const char value 
)
static

Definition at line 1393 of file h2_util.c.

◆ create_int()

static apr_status_t create_int ( h2_fifo **  pfifo,
apr_pool_t pool,
int  capacity,
int  as_set 
)
static

Definition at line 562 of file h2_util.c.

◆ fifo_destroy()

static apr_status_t fifo_destroy ( void *  data)
static

Definition at line 539 of file h2_util.c.

◆ fifo_peek()

static apr_status_t fifo_peek ( h2_fifo fifo,
h2_fifo_peek_fn fn,
void *  ctx,
int  block 
)
static

Definition at line 746 of file h2_util.c.

◆ fifo_pull()

static apr_status_t fifo_pull ( h2_fifo fifo,
void **  pelem,
int  block 
)
static

Definition at line 725 of file h2_util.c.

◆ fifo_push()

static apr_status_t fifo_push ( h2_fifo fifo,
void *  elem,
int  block 
)
static

Definition at line 683 of file h2_util.c.

◆ fifo_push_int()

static apr_status_t fifo_push_int ( h2_fifo fifo,
void *  elem,
int  block 
)
static

Definition at line 648 of file h2_util.c.

◆ fit_bucket_into()

static void fit_bucket_into ( apr_bucket b,
apr_off_t plen 
)
static

Definition at line 1173 of file h2_util.c.

◆ h2_append_brigade()

apr_status_t h2_append_brigade ( apr_bucket_brigade to,
apr_bucket_brigade from,
apr_off_t plen,
int peos,
h2_bucket_gate should_append 
)

Transfer buckets from one brigade to another with a limit on the maximum amount of bytes transferred. Does no setaside magic, lifetime of brigades must fit.

Parameters
tobrigade to transfer buckets to
frombrigades to remove buckets from
plenmaximum bytes to transfer, actual bytes transferred
peosif an EOS bucket was transferred

Definition at line 1320 of file h2_util.c.

◆ h2_brigade_concat_length()

apr_status_t h2_brigade_concat_length ( apr_bucket_brigade dest,
apr_bucket_brigade src,
apr_off_t  length 
)

Concatenate at most length bytes from src to dest brigade, splitting buckets if necessary and reading buckets of indeterminate length.

Definition at line 1193 of file h2_util.c.

◆ h2_brigade_copy_length()

apr_status_t h2_brigade_copy_length ( apr_bucket_brigade dest,
apr_bucket_brigade src,
apr_off_t  length 
)

Copy at most length bytes from src to dest brigade, splitting buckets if necessary and reading buckets of indeterminate length.

Definition at line 1228 of file h2_util.c.

◆ h2_brigade_mem_size()

apr_off_t h2_brigade_mem_size ( apr_bucket_brigade bb)

Get an approximnation of the memory footprint of the given brigade. This varies from apr_brigade_length as

  • no buckets are ever read
  • only buckets known to allocate memory (HEAP+POOL) are counted
  • the bucket struct itself is counted

Definition at line 1368 of file h2_util.c.

◆ h2_fifo_count()

int h2_fifo_count ( h2_fifo fifo)

Definition at line 624 of file h2_util.c.

◆ h2_fifo_create()

apr_status_t h2_fifo_create ( h2_fifo **  pfifo,
apr_pool_t pool,
int  capacity 
)

Create a FIFO queue that can hold up to capacity elements. Elements can appear several times.

Definition at line 602 of file h2_util.c.

◆ h2_fifo_peek()

apr_status_t h2_fifo_peek ( h2_fifo fifo,
h2_fifo_peek_fn fn,
void *  ctx 
)

Call given function on the head of the queue, once it exists, and perform the returned operation on it. The queue will hold its lock during this time, so no other operations on the queue are possible.

Parameters
fifothe queue to peek at
fnthe function to call on the head, once available
ctxcontext to pass in call to function

Definition at line 770 of file h2_util.c.

◆ h2_fifo_pull()

apr_status_t h2_fifo_pull ( h2_fifo fifo,
void **  pelem 
)

Definition at line 736 of file h2_util.c.

◆ h2_fifo_push()

apr_status_t h2_fifo_push ( h2_fifo fifo,
void *  elem 
)

Push en element into the queue. Blocks if there is no capacity left.

Parameters
fifothe FIFO queue
elemthe element to push
Returns
APR_SUCCESS on push, APR_EAGAIN on try_push on a full queue, APR_EEXIST when in set mode and elem already there.

Definition at line 694 of file h2_util.c.

◆ h2_fifo_remove()

apr_status_t h2_fifo_remove ( h2_fifo fifo,
void *  elem 
)

Remove the elem from the queue, will remove multiple appearances.

Parameters
elemthe element to remove
Returns
APR_SUCCESS iff > 0 elems were removed, APR_EAGAIN otherwise.

Definition at line 780 of file h2_util.c.

◆ h2_fifo_set_create()

apr_status_t h2_fifo_set_create ( h2_fifo **  pfifo,
apr_pool_t pool,
int  capacity 
)

Create a FIFO set that can hold up to capacity elements. Elements only appear once. Pushing an element already present does not change the queue and is successful.

Definition at line 607 of file h2_util.c.

◆ h2_fifo_term()

apr_status_t h2_fifo_term ( h2_fifo fifo)

Definition at line 612 of file h2_util.c.

◆ h2_fifo_try_peek()

apr_status_t h2_fifo_try_peek ( h2_fifo fifo,
h2_fifo_peek_fn fn,
void *  ctx 
)

Non-blocking version of h2_fifo_peek.

Definition at line 775 of file h2_util.c.

◆ h2_fifo_try_pull()

apr_status_t h2_fifo_try_pull ( h2_fifo fifo,
void **  pelem 
)

Definition at line 741 of file h2_util.c.

◆ h2_fifo_try_push()

apr_status_t h2_fifo_try_push ( h2_fifo fifo,
void *  elem 
)

Definition at line 699 of file h2_util.c.

◆ h2_ififo_count()

int h2_ififo_count ( h2_ififo fifo)

Definition at line 954 of file h2_util.c.

◆ h2_ififo_create()

apr_status_t h2_ififo_create ( h2_ififo **  pfifo,
apr_pool_t pool,
int  capacity 
)

Create a FIFO queue that can hold up to capacity int. ints can appear several times.

Definition at line 932 of file h2_util.c.

◆ h2_ififo_peek()

apr_status_t h2_ififo_peek ( h2_ififo fifo,
h2_ififo_peek_fn fn,
void *  ctx 
)

Call given function on the head of the queue, once it exists, and perform the returned operation on it. The queue will hold its lock during this time, so no other operations on the queue are possible.

Parameters
fifothe queue to peek at
fnthe function to call on the head, once available
ctxcontext to pass in call to function

Definition at line 1087 of file h2_util.c.

◆ h2_ififo_pull()

apr_status_t h2_ififo_pull ( h2_ififo fifo,
int pi 
)

Definition at line 1057 of file h2_util.c.

◆ h2_ififo_push()

apr_status_t h2_ififo_push ( h2_ififo fifo,
int  id 
)

Push an int into the queue. Blocks if there is no capacity left.

Parameters
fifothe FIFO queue
idthe int to push
Returns
APR_SUCCESS on push, APR_EAGAIN on try_push on a full queue, APR_EEXIST when in set mode and elem already there.

Definition at line 1017 of file h2_util.c.

◆ h2_ififo_remove()

apr_status_t h2_ififo_remove ( h2_ififo fifo,
int  id 
)

Remove the integer from the queue, will remove multiple appearances.

Parameters
idthe integer to remove
Returns
APR_SUCCESS iff > 0 ints were removed, APR_EAGAIN otherwise.

Definition at line 1125 of file h2_util.c.

◆ h2_ififo_set_create()

apr_status_t h2_ififo_set_create ( h2_ififo **  pfifo,
apr_pool_t pool,
int  capacity 
)

Create a FIFO set that can hold up to capacity integers. Ints only appear once. Pushing an int already present does not change the queue and is successful.

Definition at line 937 of file h2_util.c.

◆ h2_ififo_term()

apr_status_t h2_ififo_term ( h2_ififo fifo)

Definition at line 942 of file h2_util.c.

◆ h2_ififo_try_peek()

apr_status_t h2_ififo_try_peek ( h2_ififo fifo,
h2_ififo_peek_fn fn,
void *  ctx 
)

Non-blocking version of h2_fifo_peek.

Definition at line 1092 of file h2_util.c.

◆ h2_ififo_try_pull()

apr_status_t h2_ififo_try_pull ( h2_ififo fifo,
int pi 
)

Definition at line 1062 of file h2_util.c.

◆ h2_ififo_try_push()

apr_status_t h2_ififo_try_push ( h2_ififo fifo,
int  id 
)

Definition at line 1022 of file h2_util.c.

◆ h2_ignore_req_trailer()

int h2_ignore_req_trailer ( const char name,
size_t  len 
)

Definition at line 1675 of file h2_util.c.

◆ h2_ignore_resp_trailer()

int h2_ignore_resp_trailer ( const char name,
size_t  len 
)

Definition at line 1685 of file h2_util.c.

◆ h2_ihash_add()

void h2_ihash_add ( h2_ihash_t ih,
void *  val 
)

Definition at line 268 of file h2_util.c.

◆ h2_ihash_clear()

void h2_ihash_clear ( h2_ihash_t ih)

Definition at line 285 of file h2_util.c.

◆ h2_ihash_count()

unsigned int h2_ihash_count ( h2_ihash_t ih)

Definition at line 233 of file h2_util.c.

◆ h2_ihash_create()

h2_ihash_t * h2_ihash_create ( apr_pool_t pool,
size_t  offset_of_int 
)

Create a hash for structures that have an identifying int member.

Parameters
poolthe pool to use
offset_of_intthe offsetof() the int member in the struct

Definition at line 225 of file h2_util.c.

◆ h2_ihash_empty()

int h2_ihash_empty ( h2_ihash_t ih)

Definition at line 238 of file h2_util.c.

◆ h2_ihash_get()

void * h2_ihash_get ( h2_ihash_t ih,
int  id 
)

Definition at line 243 of file h2_util.c.

◆ h2_ihash_iter()

int h2_ihash_iter ( h2_ihash_t ih,
h2_ihash_iter_t fn,
void *  ctx 
)

Iterate over the hash members (without defined order) and invoke fn for each member until 0 is returned.

Parameters
ihthe hash to iterate over
fnthe function to invoke on each member
ctxuser supplied data passed into each iteration call
Returns
0 if one iteration returned 0, otherwise != 0

Definition at line 260 of file h2_util.c.

◆ h2_ihash_remove()

void h2_ihash_remove ( h2_ihash_t ih,
int  id 
)

Definition at line 273 of file h2_util.c.

◆ h2_ihash_remove_val()

void h2_ihash_remove_val ( h2_ihash_t ih,
void *  val 
)

Definition at line 278 of file h2_util.c.

◆ h2_ihash_shift()

size_t h2_ihash_shift ( h2_ihash_t ih,
void **  buffer,
size_t  max 
)

Definition at line 307 of file h2_util.c.

◆ h2_iq_add()

int h2_iq_add ( h2_iqueue q,
int  sid,
h2_iq_cmp cmp,
void *  ctx 
)

Add a stream id to the queue.

Parameters
qthe queue to append the id to
sidthe stream id to add
cmpthe comparator for sorting
ctxuser data for comparator
Returns
!= 0 iff id was not already there

Definition at line 354 of file h2_util.c.

◆ h2_iq_append()

int h2_iq_append ( h2_iqueue q,
int  sid 
)

Append the id to the queue if not already present.

Parameters
qthe queue to append the id to
sidthe id to append
Returns
!= 0 iff id was not already there

Definition at line 375 of file h2_util.c.

◆ h2_iq_clear()

void h2_iq_clear ( h2_iqueue q)

Remove all entries in the queue.

Definition at line 400 of file h2_util.c.

◆ h2_iq_contains()

int h2_iq_contains ( h2_iqueue q,
int  sid 
)

Determine if int is in the queue already

Parameters
qthe queue
sidthe integer id to check for
Returns
!= 0 iff sid is already in the queue

Definition at line 511 of file h2_util.c.

◆ h2_iq_count()

int h2_iq_count ( h2_iqueue q)

Return the number of int in the queue.

Parameters
qthe queue to get size on

Definition at line 348 of file h2_util.c.

◆ h2_iq_create()

h2_iqueue * h2_iq_create ( apr_pool_t pool,
int  capacity 
)

Allocate a new queue from the pool and initialize.

Parameters
poolthe memory pool
capacitythe initial capacity of the queue

Definition at line 334 of file h2_util.c.

◆ h2_iq_empty()

int h2_iq_empty ( h2_iqueue q)

Return != 0 iff there are no ints in the queue.

Parameters
qthe queue to check

Definition at line 343 of file h2_util.c.

◆ h2_iq_mshift()

size_t h2_iq_mshift ( h2_iqueue q,
int pint,
size_t  max 
)

Get the first max ids from the queue. All these ids will be removed.

Parameters
qthe queue to get the first ids from
pintthe int array to receive the values
maxthe maximum number of ids to shift
Returns
the actual number of ids shifted

Definition at line 448 of file h2_util.c.

◆ h2_iq_remove()

int h2_iq_remove ( h2_iqueue q,
int  sid 
)

Remove the int from the queue. Return != 0 iff it was found.

Parameters
qthe queue
sidthe stream id to remove
Returns
!= 0 iff int was found in queue

Definition at line 380 of file h2_util.c.

◆ h2_iq_shift()

int h2_iq_shift ( h2_iqueue q)

Get the first id from the queue or 0 if the queue is empty. The id is being removed.

Parameters
qthe queue to get the first id from
Returns
the first id of the queue, 0 if empty

Definition at line 433 of file h2_util.c.

◆ h2_iq_sort()

void h2_iq_sort ( h2_iqueue q,
h2_iq_cmp cmp,
void *  ctx 
)

Sort the stream idqueue again. Call if the int ordering has changed.

Parameters
qthe queue to sort
cmpthe comparator for sorting
ctxuser data for the comparator

Definition at line 405 of file h2_util.c.

◆ h2_log2()

unsigned char h2_log2 ( int  n)

Definition at line 35 of file h2_util.c.

◆ h2_push_policy_determine()

int h2_push_policy_determine ( apr_table_t headers,
apr_pool_t p,
int  push_enabled 
)

Set the push policy for the given request. Takes request headers into account, see draft https://tools.ietf.org/html/draft-ruellan-http-accept-push-policy-00 for details.

Parameters
headersthe http headers to inspect
pthe pool to use
push_enabledif HTTP/2 server push is generally enabled for this request
Returns
the push policy desired

Definition at line 1852 of file h2_util.c.

◆ h2_req_add_header()

apr_status_t h2_req_add_header ( apr_table_t headers,
apr_pool_t pool,
const char name,
size_t  nlen,
const char value,
size_t  vlen,
size_t  max_field_len,
int pwas_added 
)

Add a HTTP/2 header and return the table key if it really was added and not ignored.

Definition at line 1751 of file h2_util.c.

◆ h2_req_create_ngheader()

apr_status_t h2_req_create_ngheader ( h2_ngheader **  ph,
apr_pool_t p,
const struct h2_request req 
)

Definition at line 1566 of file h2_util.c.

◆ h2_req_ignore_header()

static int h2_req_ignore_header ( nghttp2_nv nv)
static

Definition at line 1670 of file h2_util.c.

◆ h2_res_create_ngheader()

apr_status_t h2_res_create_ngheader ( h2_ngheader **  ph,
apr_pool_t p,
h2_headers headers 
)

Definition at line 1551 of file h2_util.c.

◆ h2_res_create_ngtrailer()

apr_status_t h2_res_create_ngtrailer ( h2_ngheader **  ph,
apr_pool_t p,
h2_headers headers 
)

Definition at line 1544 of file h2_util.c.

◆ h2_util_base64url_decode()

apr_size_t h2_util_base64url_decode ( const char **  decoded,
const char encoded,
apr_pool_t pool 
)

I always wanted to write my own base64url decoder...not. See https://tools.ietf.org/html/rfc4648#section-5 for description.

Definition at line 133 of file h2_util.c.

◆ h2_util_base64url_encode()

const char * h2_util_base64url_encode ( const char data,
apr_size_t  dlen,
apr_pool_t pool 
)

Definition at line 182 of file h2_util.c.

◆ h2_util_bb_print()

apr_size_t h2_util_bb_print ( char buffer,
apr_size_t  bmax,
const char tag,
const char sep,
apr_bucket_brigade bb 
)

Prints the brigade bucket types and lengths into the given buffer up to bmax.

Returns
number of characters printed

Definition at line 1290 of file h2_util.c.

◆ h2_util_bucket_print()

apr_size_t h2_util_bucket_print ( char buffer,
apr_size_t  bmax,
apr_bucket b,
const char sep 
)

Print a bucket's meta data (type and length) to the buffer.

Returns
number of characters printed

Definition at line 1267 of file h2_util.c.

◆ h2_util_camel_case_header()

void h2_util_camel_case_header ( char s,
size_t  len 
)

Definition at line 80 of file h2_util.c.

◆ h2_util_drain_pipe()

void h2_util_drain_pipe ( apr_file_t pipe)

Drain a pipe used for notification.

Definition at line 1882 of file h2_util.c.

◆ h2_util_frame_print()

int h2_util_frame_print ( const nghttp2_frame frame,
char buffer,
size_t  maxlen 
)

Definition at line 1769 of file h2_util.c.

◆ h2_util_hex_dump()

size_t h2_util_hex_dump ( char buffer,
size_t  maxlen,
const char data,
size_t  datalen 
)

Definition at line 64 of file h2_util.c.

◆ h2_util_ignore_resp_header()

int h2_util_ignore_resp_header ( const char name)

Definition at line 1660 of file h2_util.c.

◆ h2_util_table_bytes()

apr_size_t h2_util_table_bytes ( apr_table_t t,
apr_size_t  pair_extra 
)

Count the bytes that all key/value pairs in a table have in length (exlucding terminating 0s), plus additional extra per pair.

Parameters
tthe table to inspect
pair_extrathe extra amount to add per pair
Returns
the number of bytes all key/value pairs have

Definition at line 1158 of file h2_util.c.

◆ h2_util_wait_on_pipe()

apr_status_t h2_util_wait_on_pipe ( apr_file_t pipe)

Wait on data arriving on a pipe.

Definition at line 1907 of file h2_util.c.

◆ icheck_not_empty()

static apr_status_t icheck_not_empty ( h2_ififo fifo,
int  block 
)
static

Definition at line 959 of file h2_util.c.

◆ icreate_int()

static apr_status_t icreate_int ( h2_ififo **  pfifo,
apr_pool_t pool,
int  capacity,
int  as_set 
)
static

Definition at line 892 of file h2_util.c.

◆ ififo_destroy()

static apr_status_t ififo_destroy ( void *  data)
static

Definition at line 869 of file h2_util.c.

◆ ififo_peek()

static apr_status_t ififo_peek ( h2_ififo fifo,
h2_ififo_peek_fn fn,
void *  ctx,
int  block 
)
static

Definition at line 1067 of file h2_util.c.

◆ ififo_pull()

static apr_status_t ififo_pull ( h2_ififo fifo,
int pi,
int  block 
)
static

Definition at line 1046 of file h2_util.c.

◆ ififo_push()

static apr_status_t ififo_push ( h2_ififo fifo,
int  id,
int  block 
)
static

Definition at line 1006 of file h2_util.c.

◆ ififo_push_int()

static apr_status_t ififo_push_int ( h2_ififo fifo,
int  id,
int  block 
)
static

Definition at line 973 of file h2_util.c.

◆ ififo_remove()

static apr_status_t ififo_remove ( h2_ififo fifo,
int  id 
)
static

Definition at line 1097 of file h2_util.c.

◆ ihash()

static unsigned int ihash ( const char key,
apr_ssize_t klen 
)
static

Definition at line 220 of file h2_util.c.

◆ ihash_iter()

static int ihash_iter ( void *  ctx,
const void *  key,
apr_ssize_t  klen,
const void *  val 
)
static

Definition at line 253 of file h2_util.c.

◆ iindex_of()

static int iindex_of ( h2_ififo fifo,
int  id 
)
static

Definition at line 880 of file h2_util.c.

◆ index_of()

static int index_of ( h2_fifo fifo,
void *  elem 
)
static

Definition at line 550 of file h2_util.c.

◆ inth_index()

static int inth_index ( h2_ififo fifo,
int  n 
)
static

Definition at line 864 of file h2_util.c.

◆ inv_field_name_chr()

static const char * inv_field_name_chr ( const char token)
static

Definition at line 1401 of file h2_util.c.

◆ inv_field_value_chr()

static const char * inv_field_value_chr ( const char token)
static

Definition at line 1410 of file h2_util.c.

◆ ipull_head()

static apr_status_t ipull_head ( h2_ififo fifo,
int pi,
int  block 
)
static

Definition at line 1027 of file h2_util.c.

◆ iq_bubble_down()

static int iq_bubble_down ( h2_iqueue q,
int  i,
int  bottom,
h2_iq_cmp cmp,
void *  ctx 
)
static

Definition at line 499 of file h2_util.c.

◆ iq_bubble_up()

static int iq_bubble_up ( h2_iqueue q,
int  i,
int  top,
h2_iq_cmp cmp,
void *  ctx 
)
static

Definition at line 487 of file h2_util.c.

◆ iq_grow()

static void iq_grow ( h2_iqueue q,
int  nlen 
)
static

Definition at line 460 of file h2_util.c.

◆ iq_swap()

static void iq_swap ( h2_iqueue q,
int  i,
int  j 
)
static

Definition at line 480 of file h2_util.c.

◆ is_unsafe()

static int is_unsafe ( h2_headers h)
static

Definition at line 1538 of file h2_util.c.

◆ ngheader_create()

static apr_status_t ngheader_create ( h2_ngheader **  ph,
apr_pool_t p,
int  unsafe,
size_t  key_count,
const char keys[],
const char values[],
apr_table_t headers 
)
static

Definition at line 1472 of file h2_util.c.

◆ pull_head()

static apr_status_t pull_head ( h2_fifo fifo,
void **  pelem,
int  block 
)
static

Definition at line 704 of file h2_util.c.

◆ req_add_header()

static apr_status_t req_add_header ( apr_table_t headers,
apr_pool_t pool,
nghttp2_nv nv,
size_t  max_field_len,
int pwas_added 
)
static

Definition at line 1695 of file h2_util.c.

◆ strip_field_value_ws()

static void strip_field_value_ws ( nghttp2_nv nv)
static

Definition at line 1416 of file h2_util.c.

Variable Documentation

◆ BASE64URL_CHARS

const unsigned char BASE64URL_CHARS[]
static
Initial value:
= {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '-', '_', ' ', ' ', ' ', ' ', ' ', ' ',
}

Definition at line 121 of file h2_util.c.

◆ BASE64URL_UINT6

const unsigned int BASE64URL_UINT6[]
static
Initial value:
= {
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , 62, (unsigned int)-1 , (unsigned int)-1 ,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , 63,
(unsigned int)-1 , 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 ,
(unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1 , (unsigned int)-1
}
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray

Definition at line 102 of file h2_util.c.

◆ IgnoredRequestHeaders

literal IgnoredRequestHeaders[]
static
Initial value:
= {
{ ( "upgrade" ), (sizeof( "upgrade" )-1) },
{ ( "connection" ), (sizeof( "connection" )-1) },
{ ( "keep-alive" ), (sizeof( "keep-alive" )-1) },
{ ( "http2-settings" ), (sizeof( "http2-settings" )-1) },
{ ( "proxy-connection" ), (sizeof( "proxy-connection" )-1) },
{ ( "transfer-encoding" ), (sizeof( "transfer-encoding" )-1) },
}

Definition at line 1604 of file h2_util.c.

◆ IgnoredRequestTrailers

literal IgnoredRequestTrailers[]
static
Initial value:
= {
{ ( "te" ), (sizeof( "te" )-1) },
{ ( "host" ), (sizeof( "host" )-1) },
{ ( "range" ), (sizeof( "range" )-1) },
{ ( "cookie" ), (sizeof( "cookie" )-1) },
{ ( "expect" ), (sizeof( "expect" )-1) },
{ ( "pragma" ), (sizeof( "pragma" )-1) },
{ ( "max-forwards" ), (sizeof( "max-forwards" )-1) },
{ ( "cache-control" ), (sizeof( "cache-control" )-1) },
{ ( "authorization" ), (sizeof( "authorization" )-1) },
{ ( "content-length" ), (sizeof( "content-length" )-1) },
{ ( "proxy-authorization" ), (sizeof( "proxy-authorization" )-1) },
}

Definition at line 1612 of file h2_util.c.

◆ IgnoredResponseHeaders

literal IgnoredResponseHeaders[]
static
Initial value:
= {
{ ( "upgrade" ), (sizeof( "upgrade" )-1) },
{ ( "connection" ), (sizeof( "connection" )-1) },
{ ( "keep-alive" ), (sizeof( "keep-alive" )-1) },
{ ( "transfer-encoding" ), (sizeof( "transfer-encoding" )-1) },
}

Definition at line 1625 of file h2_util.c.

◆ IgnoredResponseTrailers

literal IgnoredResponseTrailers[]
static
Initial value:
= {
{ ( "age" ), (sizeof( "age" )-1) },
{ ( "date" ), (sizeof( "date" )-1) },
{ ( "vary" ), (sizeof( "vary" )-1) },
{ ( "cookie" ), (sizeof( "cookie" )-1) },
{ ( "expires" ), (sizeof( "expires" )-1) },
{ ( "warning" ), (sizeof( "warning" )-1) },
{ ( "location" ), (sizeof( "location" )-1) },
{ ( "retry-after" ), (sizeof( "retry-after" )-1) },
{ ( "cache-control" ), (sizeof( "cache-control" )-1) },
{ ( "www-authenticate" ), (sizeof( "www-authenticate" )-1) },
{ ( "proxy-authenticate" ), (sizeof( "proxy-authenticate" )-1) },
}

Definition at line 1631 of file h2_util.c.