Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
201ab1a1
Commit
201ab1a1
authored
Jan 21, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp2_hd: Adjust maximum size to index based on table size
parent
72aef67c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
36 deletions
+13
-36
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+8
-3
lib/nghttp2_hd.h
lib/nghttp2_hd.h
+0
-1
tests/nghttp2_hd_test.c
tests/nghttp2_hd_test.c
+5
-32
No files found.
lib/nghttp2_hd.c
View file @
201ab1a1
...
...
@@ -926,8 +926,14 @@ nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context,
#define name_match(NV, NAME) \
(nv->namelen == sizeof(NAME) - 1 && memeq(nv->name, NAME, sizeof(NAME) - 1))
static
int
should_indexing
(
const
nghttp2_nv
*
nv
)
static
int
hd_deflate_should_indexing
(
nghttp2_hd_context
*
deflater
,
const
nghttp2_nv
*
nv
)
{
size_t
table_size
=
nghttp2_min
(
deflater
->
deflate_hd_table_bufsize_max
,
deflater
->
hd_table_bufsize_max
);
if
(
entry_room
(
nv
->
namelen
,
nv
->
valuelen
)
>
table_size
*
3
/
4
)
{
return
0
;
}
#ifdef NGHTTP2_XHD
return
!
name_match
(
nv
,
NGHTTP2_XHD
);
#else
/* !NGHTTP2_XHD */
...
...
@@ -1020,8 +1026,7 @@ static int deflate_nv(nghttp2_hd_context *deflater,
if
(
res
.
index
!=
-
1
)
{
index
=
res
.
index
;
}
if
(
should_indexing
(
nv
)
&&
entry_room
(
nv
->
namelen
,
nv
->
valuelen
)
<=
NGHTTP2_HD_MAX_ENTRY_SIZE
)
{
if
(
hd_deflate_should_indexing
(
deflater
,
nv
))
{
nghttp2_hd_entry
*
new_ent
;
if
(
index
>=
(
ssize_t
)
deflater
->
hd_table
.
len
)
{
nghttp2_nv
nv_indname
;
...
...
lib/nghttp2_hd.h
View file @
201ab1a1
...
...
@@ -32,7 +32,6 @@
#include <nghttp2/nghttp2.h>
#define NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE (1 << 12)
#define NGHTTP2_HD_MAX_ENTRY_SIZE 3072
#define NGHTTP2_HD_ENTRY_OVERHEAD 32
/* Default size of maximum table buffer size for encoder. Even if
...
...
tests/nghttp2_hd_test.c
View file @
201ab1a1
...
...
@@ -331,10 +331,11 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
0
,
&
nv3
,
1
);
CU_ASSERT
(
blocklen
>
0
);
/* Now header table should be empty */
CU_ASSERT
(
0
==
deflater
.
hd_table
.
len
);
CU_ASSERT
(
0
==
deflater
.
deflate_hd_tablelen
);
CU_ASSERT
(
0
==
deflater
.
deflate_hd_table_bufsize
);
/* Now header table should be unchanged, because we don't index
large header */
CU_ASSERT
(
4
==
deflater
.
hd_table
.
len
);
CU_ASSERT
(
4
==
deflater
.
deflate_hd_tablelen
);
CU_ASSERT
(
156
==
deflater
.
deflate_hd_table_bufsize
);
nghttp2_hd_deflate_free
(
&
deflater
);
...
...
@@ -401,34 +402,6 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
nva_out_reset
(
&
out
);
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
0
,
&
nv3
,
1
);
CU_ASSERT
(
blocklen
>
0
);
/* Now header table should look like this:
*
* 0: a..a, a..a (-)
* 1: k1, v1 (-)
* 2: k1000, v100 (-)
* 3: k100, v100 (-)
* 4: k10, v10 (-)
* 5: k1, v1 (-)
*
* name/value of all entries must be NULL.
*/
CU_ASSERT
(
6
==
deflater
.
hd_table
.
len
);
CU_ASSERT
(
0
==
deflater
.
deflate_hd_tablelen
);
CU_ASSERT
(
0
==
deflater
.
deflate_hd_table_bufsize
);
for
(
i
=
0
;
i
<
6
;
++
i
)
{
ent
=
nghttp2_hd_table_get
(
&
deflater
,
i
);
CU_ASSERT
(
0
==
(
ent
->
flags
&
NGHTTP2_HD_FLAG_REFSET
));
}
CU_ASSERT
(
blocklen
==
inflate_hd
(
&
inflater
,
&
out
,
buf
,
blocklen
));
CU_ASSERT
(
1
==
out
.
nvlen
);
assert_nv_equal
(
&
nv3
,
out
.
nva
,
1
);
nva_out_reset
(
&
out
);
free
(
buf
);
nghttp2_hd_inflate_free
(
&
inflater
);
nghttp2_hd_deflate_free
(
&
deflater
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment