mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Update HPACK interface
This commit is contained in:
parent
a07c3aaa16
commit
6a4060db0e
3 changed files with 115 additions and 4 deletions
|
@ -450,8 +450,9 @@ write_headers (struct lsquic_frame_writer *fw,
|
||||||
for (i = 0; i < headers->count; ++i)
|
for (i = 0; i < headers->count; ++i)
|
||||||
{
|
{
|
||||||
end = lshpack_enc_encode(fw->fw_henc, buf, buf + buf_sz,
|
end = lshpack_enc_encode(fw->fw_henc, buf, buf + buf_sz,
|
||||||
headers->headers[i].name.iov_base, headers->headers[i].name.iov_len,
|
LSHPACK_HDR_UNKNOWN,
|
||||||
headers->headers[i].value.iov_base, headers->headers[i].value.iov_len, 0);
|
(const lshpack_header_t *)&headers->headers[i],
|
||||||
|
0);
|
||||||
if (end > buf)
|
if (end > buf)
|
||||||
{
|
{
|
||||||
s = hfc_write(hfc, buf, end - buf);
|
s = hfc_write(hfc, buf, end - buf);
|
||||||
|
|
|
@ -6087,7 +6087,7 @@ lshpack_enc_push_entry (struct lshpack_enc *enc, const char *name,
|
||||||
|
|
||||||
|
|
||||||
unsigned char *
|
unsigned char *
|
||||||
lshpack_enc_encode (struct lshpack_enc *enc, unsigned char *dst,
|
lshpack_enc_encode2 (struct lshpack_enc *enc, unsigned char *dst,
|
||||||
unsigned char *dst_end, const char *name, lshpack_strlen_t name_len,
|
unsigned char *dst_end, const char *name, lshpack_strlen_t name_len,
|
||||||
const char *value, lshpack_strlen_t value_len, int indexed_type)
|
const char *value, lshpack_strlen_t value_len, int indexed_type)
|
||||||
{
|
{
|
||||||
|
@ -6151,6 +6151,16 @@ lshpack_enc_encode (struct lshpack_enc *enc, unsigned char *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char *
|
||||||
|
lshpack_enc_encode (struct lshpack_enc *henc, unsigned char *dst,
|
||||||
|
unsigned char *dst_end, int hpack_idx,
|
||||||
|
const lshpack_header_t *hdr, int indexed_type)
|
||||||
|
{
|
||||||
|
return lshpack_enc_encode2(henc, dst, dst_end, hdr->name.iov_base,
|
||||||
|
hdr->name.iov_len, hdr->value.iov_base, hdr->value.iov_len, indexed_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
lshpack_enc_set_max_capacity (struct lshpack_enc *enc, unsigned max_capacity)
|
lshpack_enc_set_max_capacity (struct lshpack_enc *enc, unsigned max_capacity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strings up to 65535 characters in length are supported.
|
* Strings up to 65535 characters in length are supported.
|
||||||
|
@ -43,6 +44,85 @@ typedef uint16_t lshpack_strlen_t;
|
||||||
struct lshpack_enc;
|
struct lshpack_enc;
|
||||||
struct lshpack_dec;
|
struct lshpack_dec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef lshpack_http_header_t
|
||||||
|
* @brief HTTP header structure. Contains header name and value.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct lshpack_header
|
||||||
|
{
|
||||||
|
struct iovec name;
|
||||||
|
struct iovec value;
|
||||||
|
} lshpack_header_t;
|
||||||
|
|
||||||
|
|
||||||
|
enum lshpack_static_hdr_idx
|
||||||
|
{
|
||||||
|
LSHPACK_HDR_UNKNOWN,
|
||||||
|
LSHPACK_HDR_AUTHORITY,
|
||||||
|
LSHPACK_HDR_METHOD_GET,
|
||||||
|
LSHPACK_HDR_METHOD_POST,
|
||||||
|
LSHPACK_HDR_PATH,
|
||||||
|
LSHPACK_HDR_PATH_INDEX_HTML,
|
||||||
|
LSHPACK_HDR_SCHEME_HTTP,
|
||||||
|
LSHPACK_HDR_SCHEME_HTTPS,
|
||||||
|
LSHPACK_HDR_STATUS_200,
|
||||||
|
LSHPACK_HDR_STATUS_204,
|
||||||
|
LSHPACK_HDR_STATUS_206,
|
||||||
|
LSHPACK_HDR_STATUS_304,
|
||||||
|
LSHPACK_HDR_STATUS_400,
|
||||||
|
LSHPACK_HDR_STATUS_404,
|
||||||
|
LSHPACK_HDR_STATUS_500,
|
||||||
|
LSHPACK_HDR_ACCEPT_CHARSET,
|
||||||
|
LSHPACK_HDR_ACCEPT_ENCODING,
|
||||||
|
LSHPACK_HDR_ACCEPT_LANGUAGE,
|
||||||
|
LSHPACK_HDR_ACCEPT_RANGES,
|
||||||
|
LSHPACK_HDR_ACCEPT,
|
||||||
|
LSHPACK_HDR_ACCESS_CONTROL_ALLOW_ORIGIN,
|
||||||
|
LSHPACK_HDR_AGE,
|
||||||
|
LSHPACK_HDR_ALLOW,
|
||||||
|
LSHPACK_HDR_AUTHORIZATION,
|
||||||
|
LSHPACK_HDR_CACHE_CONTROL,
|
||||||
|
LSHPACK_HDR_CONTENT_DISPOSITION,
|
||||||
|
LSHPACK_HDR_CONTENT_ENCODING,
|
||||||
|
LSHPACK_HDR_CONTENT_LANGUAGE,
|
||||||
|
LSHPACK_HDR_CONTENT_LENGTH,
|
||||||
|
LSHPACK_HDR_CONTENT_LOCATION,
|
||||||
|
LSHPACK_HDR_CONTENT_RANGE,
|
||||||
|
LSHPACK_HDR_CONTENT_TYPE,
|
||||||
|
LSHPACK_HDR_COOKIE,
|
||||||
|
LSHPACK_HDR_DATE,
|
||||||
|
LSHPACK_HDR_ETAG,
|
||||||
|
LSHPACK_HDR_EXPECT,
|
||||||
|
LSHPACK_HDR_EXPIRES,
|
||||||
|
LSHPACK_HDR_FROM,
|
||||||
|
LSHPACK_HDR_HOST,
|
||||||
|
LSHPACK_HDR_IF_MATCH,
|
||||||
|
LSHPACK_HDR_IF_MODIFIED_SINCE,
|
||||||
|
LSHPACK_HDR_IF_NONE_MATCH,
|
||||||
|
LSHPACK_HDR_IF_RANGE,
|
||||||
|
LSHPACK_HDR_IF_UNMODIFIED_SINCE,
|
||||||
|
LSHPACK_HDR_LAST_MODIFIED,
|
||||||
|
LSHPACK_HDR_LINK,
|
||||||
|
LSHPACK_HDR_LOCATION,
|
||||||
|
LSHPACK_HDR_MAX_FORWARDS,
|
||||||
|
LSHPACK_HDR_PROXY_AUTHENTICATE,
|
||||||
|
LSHPACK_HDR_PROXY_AUTHORIZATION,
|
||||||
|
LSHPACK_HDR_RANGE,
|
||||||
|
LSHPACK_HDR_REFERER,
|
||||||
|
LSHPACK_HDR_REFRESH,
|
||||||
|
LSHPACK_HDR_RETRY_AFTER,
|
||||||
|
LSHPACK_HDR_SERVER,
|
||||||
|
LSHPACK_HDR_SET_COOKIE,
|
||||||
|
LSHPACK_HDR_STRICT_TRANSPORT_SECURITY,
|
||||||
|
LSHPACK_HDR_TRANSFER_ENCODING,
|
||||||
|
LSHPACK_HDR_USER_AGENT,
|
||||||
|
LSHPACK_HDR_VARY,
|
||||||
|
LSHPACK_HDR_VIA,
|
||||||
|
LSHPACK_HDR_WWW_AUTHENTICATE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization routine allocates memory. -1 is returned if memory
|
* Initialization routine allocates memory. -1 is returned if memory
|
||||||
* could not be allocated. 0 is returned on success.
|
* could not be allocated. 0 is returned on success.
|
||||||
|
@ -72,10 +152,30 @@ lshpack_enc_cleanup (struct lshpack_enc *);
|
||||||
* pointer was not advanced, an error must have occurred.
|
* pointer was not advanced, an error must have occurred.
|
||||||
*/
|
*/
|
||||||
unsigned char *
|
unsigned char *
|
||||||
lshpack_enc_encode (struct lshpack_enc *henc, unsigned char *dst,
|
lshpack_enc_encode2 (struct lshpack_enc *henc, unsigned char *dst,
|
||||||
unsigned char *dst_end, const char *name, lshpack_strlen_t name_len,
|
unsigned char *dst_end, const char *name, lshpack_strlen_t name_len,
|
||||||
const char *value, lshpack_strlen_t value_len, int indexed_type);
|
const char *value, lshpack_strlen_t value_len, int indexed_type);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encode one name/value pair
|
||||||
|
*
|
||||||
|
* @param[in,out] henc - A pointer to a valid HPACK API struct
|
||||||
|
* @param[out] dst - A pointer to destination buffer
|
||||||
|
* @param[out] dst_end - A pointer to end of destination buffer
|
||||||
|
* @param[in] hpack_idx - The position of header name in static table,
|
||||||
|
* 0 = unknown, < 0 not in static table, 1 - 63 the position
|
||||||
|
* @param[in] hdr - the header name and value
|
||||||
|
* @param[in] indexed_type - 0, Add, 1,: without, 2: never
|
||||||
|
*
|
||||||
|
* @return The (possibly advanced) dst pointer. If the destination
|
||||||
|
* pointer was not advanced, an error must have occurred.
|
||||||
|
*/
|
||||||
|
unsigned char *
|
||||||
|
lshpack_enc_encode (struct lshpack_enc *henc, unsigned char *dst,
|
||||||
|
unsigned char *dst_end, int hpack_idx,
|
||||||
|
const lshpack_header_t *hdr, int indexed_type);
|
||||||
|
|
||||||
void
|
void
|
||||||
lshpack_enc_set_max_capacity (struct lshpack_enc *, unsigned);
|
lshpack_enc_set_max_capacity (struct lshpack_enc *, unsigned);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue