nghttp2_hd: Provide dedicated function to enable no reference set feature
This commit is contained in:
parent
41104f7b63
commit
e61876ccbd
|
@ -384,8 +384,8 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nghttp2_hd_deflate_init2(&deflater, config.side, config.deflate_table_size,
|
nghttp2_hd_deflate_init2(&deflater, config.side, config.deflate_table_size);
|
||||||
config.no_refset);
|
nghttp2_hd_deflate_set_no_refset(&deflater, config.no_refset);
|
||||||
nghttp2_hd_change_table_size(&deflater, config.table_size);
|
nghttp2_hd_change_table_size(&deflater, config.table_size);
|
||||||
if(config.http1text) {
|
if(config.http1text) {
|
||||||
perform_from_http1text(&deflater);
|
perform_from_http1text(&deflater);
|
||||||
|
|
|
@ -246,14 +246,13 @@ static void nghttp2_hd_ringbuf_pop_back(nghttp2_hd_ringbuf *ringbuf)
|
||||||
static int nghttp2_hd_context_init(nghttp2_hd_context *context,
|
static int nghttp2_hd_context_init(nghttp2_hd_context *context,
|
||||||
nghttp2_hd_role role,
|
nghttp2_hd_role role,
|
||||||
nghttp2_hd_side side,
|
nghttp2_hd_side side,
|
||||||
size_t deflate_hd_table_bufsize_max,
|
size_t deflate_hd_table_bufsize_max)
|
||||||
uint8_t no_refset)
|
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
context->role = role;
|
context->role = role;
|
||||||
context->side = side;
|
context->side = side;
|
||||||
context->bad = 0;
|
context->bad = 0;
|
||||||
context->no_refset = no_refset;
|
context->no_refset = 0;
|
||||||
context->hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
|
context->hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
|
||||||
rv = nghttp2_hd_ringbuf_init
|
rv = nghttp2_hd_ringbuf_init
|
||||||
(&context->hd_table,
|
(&context->hd_table,
|
||||||
|
@ -279,24 +278,20 @@ static int nghttp2_hd_context_init(nghttp2_hd_context *context,
|
||||||
int nghttp2_hd_deflate_init(nghttp2_hd_context *deflater, nghttp2_hd_side side)
|
int nghttp2_hd_deflate_init(nghttp2_hd_context *deflater, nghttp2_hd_side side)
|
||||||
{
|
{
|
||||||
return nghttp2_hd_context_init(deflater, NGHTTP2_HD_ROLE_DEFLATE, side,
|
return nghttp2_hd_context_init(deflater, NGHTTP2_HD_ROLE_DEFLATE, side,
|
||||||
NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE,
|
NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE);
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int nghttp2_hd_deflate_init2(nghttp2_hd_context *deflater,
|
int nghttp2_hd_deflate_init2(nghttp2_hd_context *deflater,
|
||||||
nghttp2_hd_side side,
|
nghttp2_hd_side side,
|
||||||
size_t deflate_hd_table_bufsize_max,
|
size_t deflate_hd_table_bufsize_max)
|
||||||
uint8_t no_refset)
|
|
||||||
{
|
{
|
||||||
return nghttp2_hd_context_init(deflater, NGHTTP2_HD_ROLE_DEFLATE, side,
|
return nghttp2_hd_context_init(deflater, NGHTTP2_HD_ROLE_DEFLATE, side,
|
||||||
deflate_hd_table_bufsize_max,
|
deflate_hd_table_bufsize_max);
|
||||||
no_refset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int nghttp2_hd_inflate_init(nghttp2_hd_context *inflater, nghttp2_hd_side side)
|
int nghttp2_hd_inflate_init(nghttp2_hd_context *inflater, nghttp2_hd_side side)
|
||||||
{
|
{
|
||||||
return nghttp2_hd_context_init(inflater, NGHTTP2_HD_ROLE_INFLATE, side, 0,
|
return nghttp2_hd_context_init(inflater, NGHTTP2_HD_ROLE_INFLATE, side, 0);
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nghttp2_hd_context_free(nghttp2_hd_context *context)
|
static void nghttp2_hd_context_free(nghttp2_hd_context *context)
|
||||||
|
@ -329,6 +324,12 @@ void nghttp2_hd_inflate_free(nghttp2_hd_context *inflater)
|
||||||
nghttp2_hd_context_free(inflater);
|
nghttp2_hd_context_free(inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nghttp2_hd_deflate_set_no_refset(nghttp2_hd_context *deflater,
|
||||||
|
uint8_t no_refset)
|
||||||
|
{
|
||||||
|
deflater->no_refset = no_refset;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t entry_room(size_t namelen, size_t valuelen)
|
static size_t entry_room(size_t namelen, size_t valuelen)
|
||||||
{
|
{
|
||||||
return NGHTTP2_HD_ENTRY_OVERHEAD + namelen + valuelen;
|
return NGHTTP2_HD_ENTRY_OVERHEAD + namelen + valuelen;
|
||||||
|
|
|
@ -188,9 +188,6 @@ int nghttp2_hd_deflate_init(nghttp2_hd_context *deflater,
|
||||||
* for header table even if the larger value is specified later in
|
* for header table even if the larger value is specified later in
|
||||||
* nghttp2_hd_change_table_size().
|
* nghttp2_hd_change_table_size().
|
||||||
*
|
*
|
||||||
* If nonzero is given in the |no_refset|, the encoder first clears
|
|
||||||
* the reference set each time on deflation.
|
|
||||||
*
|
|
||||||
* This function returns 0 if it succeeds, or one of the following
|
* This function returns 0 if it succeeds, or one of the following
|
||||||
* negative error codes:
|
* negative error codes:
|
||||||
*
|
*
|
||||||
|
@ -199,8 +196,7 @@ int nghttp2_hd_deflate_init(nghttp2_hd_context *deflater,
|
||||||
*/
|
*/
|
||||||
int nghttp2_hd_deflate_init2(nghttp2_hd_context *deflater,
|
int nghttp2_hd_deflate_init2(nghttp2_hd_context *deflater,
|
||||||
nghttp2_hd_side side,
|
nghttp2_hd_side side,
|
||||||
size_t deflate_hd_table_bufsize_max,
|
size_t deflate_hd_table_bufsize_max);
|
||||||
uint8_t no_refset);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes |inflater| for inflating name/values pairs.
|
* Initializes |inflater| for inflating name/values pairs.
|
||||||
|
@ -224,6 +220,14 @@ void nghttp2_hd_deflate_free(nghttp2_hd_context *deflater);
|
||||||
*/
|
*/
|
||||||
void nghttp2_hd_inflate_free(nghttp2_hd_context *inflater);
|
void nghttp2_hd_inflate_free(nghttp2_hd_context *inflater);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the availability of reference set in the |deflater|. If
|
||||||
|
* |no_refset| is nonzero, the deflater will first emit index=0 in the
|
||||||
|
* each invocation of nghttp2_hd_deflate_hd() to clear up reference
|
||||||
|
* set. By default, the deflater uses reference set.
|
||||||
|
*/
|
||||||
|
void nghttp2_hd_deflate_set_no_refset(nghttp2_hd_context *deflater,
|
||||||
|
uint8_t no_refset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes header table size in |context|. This may trigger eviction
|
* Changes header table size in |context|. This may trigger eviction
|
||||||
|
|
|
@ -278,7 +278,7 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
|
||||||
/* Check the case where entry from static table is inserted to
|
/* Check the case where entry from static table is inserted to
|
||||||
dynamic header table. And it is out of deflate header table
|
dynamic header table. And it is out of deflate header table
|
||||||
size. */
|
size. */
|
||||||
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 32, 0);
|
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 32);
|
||||||
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
||||||
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
||||||
nva4, ARRLEN(nva4));
|
nva4, ARRLEN(nva4));
|
||||||
|
@ -310,7 +310,7 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
|
||||||
nghttp2_hd_inflate_free(&inflater);
|
nghttp2_hd_inflate_free(&inflater);
|
||||||
|
|
||||||
/* 156 buffer size can hold all headers in deflate region */
|
/* 156 buffer size can hold all headers in deflate region */
|
||||||
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 156, 0);
|
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 156);
|
||||||
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
||||||
nva1, ARRLEN(nva1));
|
nva1, ARRLEN(nva1));
|
||||||
CU_ASSERT(blocklen > 0);
|
CU_ASSERT(blocklen > 0);
|
||||||
|
@ -344,7 +344,7 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
|
||||||
nghttp2_hd_deflate_free(&deflater);
|
nghttp2_hd_deflate_free(&deflater);
|
||||||
|
|
||||||
/* Check more complex use case */
|
/* Check more complex use case */
|
||||||
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 155, 0);
|
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST, 155);
|
||||||
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
||||||
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
blocklen = nghttp2_hd_deflate_hd(&deflater, &buf, &buflen, 0,
|
||||||
nva1, ARRLEN(nva1));
|
nva1, ARRLEN(nva1));
|
||||||
|
@ -452,7 +452,8 @@ void test_nghttp2_hd_deflate_clear_refset(void)
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST,
|
nghttp2_hd_deflate_init2(&deflater, NGHTTP2_HD_SIDE_REQUEST,
|
||||||
NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE, 1);
|
NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE);
|
||||||
|
nghttp2_hd_deflate_set_no_refset(&deflater, 1);
|
||||||
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
||||||
|
|
||||||
for(i = 0; i < 2; ++i) {
|
for(i = 0; i < 2; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue