Release 2.14.0

- [API] Use lsxpack_header structure to send HTTP headers.
- [OPTIMIZATION] nocopy's readable_bytes() function.
- http_server: fix typo in error message
- Use ls-hpack 2.1.0.
- Use ls-qpack 2.0.0.
This commit is contained in:
Dmitri Tikhonov 2020-03-30 13:34:43 -04:00
parent a686ef2a56
commit 55613f4414
31 changed files with 10666 additions and 10735 deletions

View file

@ -24,8 +24,8 @@ extern "C" {
#endif
#define LSQUIC_MAJOR_VERSION 2
#define LSQUIC_MINOR_VERSION 13
#define LSQUIC_PATCH_VERSION 3
#define LSQUIC_MINOR_VERSION 14
#define LSQUIC_PATCH_VERSION 0
/**
* Engine flags:
@ -198,6 +198,7 @@ struct lsquic_stream_if {
struct ssl_ctx_st;
struct ssl_st;
struct lsxpack_header;
/**
* QUIC engine in server role needs access to certificates. This is
@ -862,6 +863,19 @@ typedef void (*lsquic_cids_update_f)(void *ctx, void **peer_ctx,
struct stack_st_X509;
enum lsquic_hsi_flag {
/**
* Turn HTTP/1.x mode on or off. In this mode, decoded name and value
* pair are separated by ": " and "\r\n" is appended to the end of the
* string. By default, this mode is off.
*/
LSQUIC_HSI_HTTP1X = 1 << 1,
/** Include name hash into lsxpack_header */
LSQUIC_HSI_HASH_NAME = 1 << 2,
/** Include nameval hash into lsxpack_header */
LSQUIC_HSI_HASH_NAMEVAL = 1 << 3,
};
struct lsquic_hset_if
{
/**
@ -869,8 +883,8 @@ struct lsquic_hset_if
* stream by calling @ref lsquic_stream_get_hset() before the stream can
* be read.
*/
void * (*hsi_create_header_set)(void *hsi_ctx,
int is_push_promise);
void * (*hsi_create_header_set)(void *hsi_ctx, lsquic_stream_t *stream,
int is_push_promise);
/**
* Return a header set prepared for decoding. If `hdr' is NULL, this
* means return a new structure with at least `space' bytes available
@ -911,6 +925,11 @@ struct lsquic_hset_if
* header sets that had an error.
*/
void (*hsi_discard_header_set)(void *hdr_set);
/**
* These flags specify properties of decoded headers passed to
* hsi_process_header().
*/
enum lsquic_hsi_flag hsi_flags;
};
/**
@ -1272,17 +1291,6 @@ lsquic_stream_writef (lsquic_stream_t *, struct lsquic_reader *);
int
lsquic_stream_flush (lsquic_stream_t *s);
/**
* @typedef lsquic_http_header_t
* @brief HTTP header structure. Contains header name and value.
*
*/
typedef struct lsquic_http_header
{
struct iovec name;
struct iovec value;
} lsquic_http_header_t;
/**
* @typedef lsquic_http_headers_t
* @brief HTTP header list structure. Contains a list of HTTP headers in key/value pairs.
@ -1291,7 +1299,7 @@ typedef struct lsquic_http_header
struct lsquic_http_headers
{
int count;
lsquic_http_header_t *headers;
struct lsxpack_header *headers;
};
/**
@ -1322,10 +1330,7 @@ lsquic_stream_get_hset (lsquic_stream_t *);
* trigger on_new_stream() event and it can be used as a regular client-
* initiated stream.
*
* If `hdr_set' is not set, it is generated by using `ea_hsi_if' callbacks.
* In either case, the header set object belongs to the connection. The
* user is not to free this object until (@ref hsi_discard_header_set) is
* called.
* `hdr_set' must be set. It is passed as-is to @lsquic_stream_get_hset.
*
* @retval 0 Stream pushed successfully.
* @retval 1 Stream push failed because it is disabled or because we hit
@ -1334,7 +1339,6 @@ lsquic_stream_get_hset (lsquic_stream_t *);
*/
int
lsquic_conn_push_stream (lsquic_conn_t *c, void *hdr_set, lsquic_stream_t *s,
const struct iovec* url, const struct iovec* authority,
const lsquic_http_headers_t *headers);
/**

View file

@ -1,6 +1,6 @@
/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */
#ifndef LSXPACK_HEADER_H_v203
#define LSXPACK_HEADER_H_v203
#ifndef LSXPACK_HEADER_H_v204
#define LSXPACK_HEADER_H_v204
#ifdef __cplusplus
extern "C" {
@ -22,6 +22,8 @@ typedef uint32_t lsxpack_strlen_t;
#error unexpected LSXPACK_MAX_STRLEN
#endif
#define LSXPACK_DEL ((char *)NULL)
enum lsxpack_flag
{
LSXPACK_HPACK_IDX = 1,
@ -52,6 +54,7 @@ struct lsxpack_header
lsxpack_strlen_t name_len; /* the length of name */
lsxpack_strlen_t val_offset; /* the offset for value in the buffer */
lsxpack_strlen_t val_len; /* the length of value */
uint16_t chain_next_idx; /* mainly for cookie value chain */
uint8_t hpack_index; /* HPACK static table index */
uint8_t qpack_index; /* QPACK static table index */
uint8_t app_index; /* APP header index */
@ -77,6 +80,20 @@ lsxpack_header_set_idx(lsxpack_header_t *hdr, int hpack_idx,
}
static inline void
lsxpack_header_set_qpack_idx(lsxpack_header_t *hdr, int qpack_idx,
const char *val, size_t val_len)
{
memset(hdr, 0, sizeof(*hdr));
hdr->buf = (char *)val;
hdr->qpack_index = qpack_idx;
assert(qpack_idx != -1);
hdr->flags = LSXPACK_QPACK_IDX;
assert(val_len <= LSXPACK_MAX_STRLEN);
hdr->val_len = val_len;
}
static inline void
lsxpack_header_set_ptr(lsxpack_header_t *hdr,
const char *name, size_t name_len,
@ -162,4 +179,4 @@ lsxpack_header_get_dec_size(const lsxpack_header_t *hdr)
}
#endif
#endif //LSXPACK_HEADER_H_v203
#endif //LSXPACK_HEADER_H_v204