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
e92b74d6
Commit
e92b74d6
authored
Jul 20, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use substitution as long as no eviction is required
parent
aa871307
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+30
-4
tests/nghttp2_hd_test.c
tests/nghttp2_hd_test.c
+3
-3
No files found.
lib/nghttp2_hd.c
View file @
e92b74d6
...
...
@@ -722,6 +722,14 @@ static void create_workingset(nghttp2_hd_context *context)
context
->
refsetlen
=
0
;
}
static
int
require_eviction_on_subst
(
nghttp2_hd_context
*
context
,
nghttp2_nv
*
nv
,
nghttp2_hd_entry
*
ent
)
{
return
context
->
capacity
-
entry_room
(
ent
->
nv
.
namelen
,
ent
->
nv
.
valuelen
)
+
entry_room
(
nv
->
namelen
,
nv
->
valuelen
)
>
NGHTTP2_MAX_HD_TABLE_CAPACITY
;
}
ssize_t
nghttp2_hd_deflate_hd
(
nghttp2_hd_context
*
deflater
,
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
size_t
nv_offset
,
...
...
@@ -755,10 +763,28 @@ ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_context *deflater,
/* Check name exists in hd_table */
ent
=
find_name_in_hd_table
(
deflater
,
&
nv
[
i
]);
if
(
ent
)
{
rv
=
emit_literal_indname_block
(
buf_ptr
,
buflen_ptr
,
&
offset
,
ent
,
nv
[
i
].
value
,
nv
[
i
].
valuelen
,
0
);
if
(
rv
<
0
)
{
return
rv
;
/* As long as no eviction kicked in, perform substitution */
if
(
require_eviction_on_subst
(
deflater
,
&
nv
[
i
],
ent
))
{
rv
=
emit_literal_indname_block
(
buf_ptr
,
buflen_ptr
,
&
offset
,
ent
,
nv
[
i
].
value
,
nv
[
i
].
valuelen
,
0
);
}
else
{
nghttp2_hd_entry
*
new_ent
;
/* No need to increment ent->ref here */
new_ent
=
add_hd_table_subst
(
deflater
,
&
nv
[
i
],
ent
->
index
);
if
(
!
new_ent
)
{
return
NGHTTP2_ERR_HEADER_COMP
;
}
rv
=
add_workingset
(
deflater
,
new_ent
);
if
(
rv
<
0
)
{
return
rv
;
}
rv
=
emit_subst_indname_block
(
buf_ptr
,
buflen_ptr
,
&
offset
,
new_ent
,
nv
[
i
].
value
,
nv
[
i
].
valuelen
,
new_ent
->
index
);
if
(
rv
<
0
)
{
return
rv
;
}
}
}
else
{
rv
=
emit_literal_block
(
buf_ptr
,
buflen_ptr
,
&
offset
,
&
nv
[
i
],
0
);
...
...
tests/nghttp2_hd_test.c
View file @
e92b74d6
...
...
@@ -62,7 +62,7 @@ void test_nghttp2_hd_deflate(void)
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
nv_offset
,
nva1
,
sizeof
(
nva1
)
/
sizeof
(
nghttp2_nv
));
CU_ASSERT
(
(
1
+
1
+
22
)
+
(
1
)
+
(
1
+
1
+
5
+
1
+
5
)
==
blocklen
);
CU_ASSERT
(
blocklen
>
0
);
nghttp2_hd_end_headers
(
&
deflater
);
CU_ASSERT
(
3
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
+
nv_offset
,
...
...
@@ -73,12 +73,12 @@ void test_nghttp2_hd_deflate(void)
nghttp2_nv_array_del
(
resnva
);
nghttp2_hd_end_headers
(
&
inflater
);
CU_ASSERT
(
1
==
inflater
.
refsetlen
);
CU_ASSERT
(
2
==
inflater
.
refsetlen
);
/* Second headers */
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
nv_offset
,
nva2
,
sizeof
(
nva2
)
/
sizeof
(
nghttp2_nv
));
CU_ASSERT
(
(
1
+
1
+
10
)
==
blocklen
);
CU_ASSERT
(
blocklen
>
0
);
nghttp2_hd_end_headers
(
&
deflater
);
CU_ASSERT
(
2
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
+
nv_offset
,
...
...
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