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
ddd04e8c
Commit
ddd04e8c
authored
Jul 27, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix header compression bug, and perform always incremental indexing
parent
20173b5f
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
101 deletions
+98
-101
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+75
-85
lib/nghttp2_hd.h
lib/nghttp2_hd.h
+4
-5
tests/nghttp2_frame_test.c
tests/nghttp2_frame_test.c
+5
-0
tests/nghttp2_hd_test.c
tests/nghttp2_hd_test.c
+6
-11
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+8
-0
No files found.
lib/nghttp2_hd.c
View file @
ddd04e8c
This diff is collapsed.
Click to expand it.
lib/nghttp2_hd.h
View file @
ddd04e8c
...
@@ -224,7 +224,7 @@ int nghttp2_hd_end_headers(nghttp2_hd_context *deflater_or_inflater);
...
@@ -224,7 +224,7 @@ int nghttp2_hd_end_headers(nghttp2_hd_context *deflater_or_inflater);
/* For unittesting purpose */
/* For unittesting purpose */
int
nghttp2_hd_emit_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
int
nghttp2_hd_emit_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
size_t
*
offset_ptr
,
nghttp2_hd_entry
*
ent
,
size_t
*
offset_ptr
,
size_t
index
,
const
uint8_t
*
value
,
size_t
valuelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
int
inc_indexing
);
int
inc_indexing
);
...
@@ -235,14 +235,13 @@ int nghttp2_hd_emit_newname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
...
@@ -235,14 +235,13 @@ int nghttp2_hd_emit_newname_block(uint8_t **buf_ptr, size_t *buflen_ptr,
/* For unittesting purpose */
/* For unittesting purpose */
int
nghttp2_hd_emit_subst_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
int
nghttp2_hd_emit_subst_indname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
size_t
*
offset_ptr
,
size_t
*
offset_ptr
,
size_t
index
,
nghttp2_hd_entry
*
ent
,
const
uint8_t
*
value
,
size_t
valuelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
size_t
index
);
size_t
sub
index
);
/* For unittesting purpose */
/* For unittesting purpose */
int
nghttp2_hd_emit_subst_newname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
int
nghttp2_hd_emit_subst_newname_block
(
uint8_t
**
buf_ptr
,
size_t
*
buflen_ptr
,
size_t
*
offset_ptr
,
nghttp2_nv
*
nv
,
size_t
*
offset_ptr
,
nghttp2_nv
*
nv
,
size_t
index
);
size_t
sub
index
);
#endif
/* NGHTTP2_HD_COMP_H */
#endif
/* NGHTTP2_HD_COMP_H */
tests/nghttp2_frame_test.c
View file @
ddd04e8c
...
@@ -119,6 +119,7 @@ void test_nghttp2_frame_pack_headers()
...
@@ -119,6 +119,7 @@ void test_nghttp2_frame_pack_headers()
nghttp2_frame_headers_init
(
&
frame
,
NGHTTP2_FLAG_END_STREAM
,
1000000007
,
nghttp2_frame_headers_init
(
&
frame
,
NGHTTP2_FLAG_END_STREAM
,
1000000007
,
1
<<
20
,
nva
,
nvlen
);
1
<<
20
,
nva
,
nvlen
);
framelen
=
nghttp2_frame_pack_headers
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
framelen
=
nghttp2_frame_pack_headers
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
nghttp2_hd_end_headers
(
&
deflater
);
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
NGHTTP2_HEADERS
,
NGHTTP2_HEADERS
,
...
@@ -133,10 +134,13 @@ void test_nghttp2_frame_pack_headers()
...
@@ -133,10 +134,13 @@ void test_nghttp2_frame_pack_headers()
CU_ASSERT
(
nvvalueeq
(
"GET"
,
&
oframe
.
nva
[
0
]));
CU_ASSERT
(
nvvalueeq
(
"GET"
,
&
oframe
.
nva
[
0
]));
nghttp2_frame_headers_free
(
&
oframe
);
nghttp2_frame_headers_free
(
&
oframe
);
nghttp2_hd_end_headers
(
&
inflater
);
memset
(
&
oframe
,
0
,
sizeof
(
oframe
));
memset
(
&
oframe
,
0
,
sizeof
(
oframe
));
/* Next, include PRIORITY flag */
/* Next, include PRIORITY flag */
frame
.
hd
.
flags
|=
NGHTTP2_FLAG_PRIORITY
;
frame
.
hd
.
flags
|=
NGHTTP2_FLAG_PRIORITY
;
framelen
=
nghttp2_frame_pack_headers
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
framelen
=
nghttp2_frame_pack_headers
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
nghttp2_hd_end_headers
(
&
deflater
);
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
NGHTTP2_HEADERS
,
NGHTTP2_HEADERS
,
...
@@ -279,6 +283,7 @@ void test_nghttp2_frame_pack_push_promise()
...
@@ -279,6 +283,7 @@ void test_nghttp2_frame_pack_push_promise()
nghttp2_frame_push_promise_init
(
&
frame
,
NGHTTP2_FLAG_END_PUSH_PROMISE
,
nghttp2_frame_push_promise_init
(
&
frame
,
NGHTTP2_FLAG_END_PUSH_PROMISE
,
1000000007
,
(
1U
<<
31
)
-
1
,
nva
,
nvlen
);
1000000007
,
(
1U
<<
31
)
-
1
,
nva
,
nvlen
);
framelen
=
nghttp2_frame_pack_push_promise
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
framelen
=
nghttp2_frame_pack_push_promise
(
&
buf
,
&
buflen
,
&
frame
,
&
deflater
);
nghttp2_hd_end_headers
(
&
deflater
);
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
CU_ASSERT
(
0
==
unpack_frame_with_nv_block
((
nghttp2_frame
*
)
&
oframe
,
NGHTTP2_PUSH_PROMISE
,
NGHTTP2_PUSH_PROMISE
,
...
...
tests/nghttp2_hd_test.c
View file @
ddd04e8c
...
@@ -81,8 +81,6 @@ void test_nghttp2_hd_deflate(void)
...
@@ -81,8 +81,6 @@ void test_nghttp2_hd_deflate(void)
nghttp2_nv_array_del
(
resnva
);
nghttp2_nv_array_del
(
resnva
);
nghttp2_hd_end_headers
(
&
inflater
);
nghttp2_hd_end_headers
(
&
inflater
);
CU_ASSERT
(
2
==
inflater
.
refsetlen
);
/* Second headers */
/* Second headers */
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
nv_offset
,
nva2
,
blocklen
=
nghttp2_hd_deflate_hd
(
&
deflater
,
&
buf
,
&
buflen
,
nv_offset
,
nva2
,
sizeof
(
nva2
)
/
sizeof
(
nghttp2_nv
));
sizeof
(
nva2
)
/
sizeof
(
nghttp2_nv
));
...
@@ -157,10 +155,8 @@ void test_nghttp2_hd_inflate_indname_inc(void)
...
@@ -157,10 +155,8 @@ void test_nghttp2_hd_inflate_indname_inc(void)
nghttp2_nv
*
resnva
;
nghttp2_nv
*
resnva
;
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
CU_ASSERT
(
0
==
nghttp2_hd_emit_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
CU_ASSERT
(
0
==
nghttp2_hd_emit_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
12
,
inflater
.
hd_table
[
12
],
nv
.
value
,
nv
.
valuelen
,
1
));
nv
.
value
,
nv
.
valuelen
,
1
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
assert_nv_equal
(
&
nv
,
resnva
,
1
);
assert_nv_equal
(
&
nv
,
resnva
,
1
);
CU_ASSERT
(
39
==
inflater
.
hd_tablelen
);
CU_ASSERT
(
39
==
inflater
.
hd_tablelen
);
...
@@ -184,8 +180,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void)
...
@@ -184,8 +180,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void)
nghttp2_nv
*
resnva
;
nghttp2_nv
*
resnva
;
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
CU_ASSERT
(
0
==
nghttp2_hd_emit_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
CU_ASSERT
(
0
==
nghttp2_hd_emit_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
2
,
inflater
.
hd_table
[
2
],
value
,
sizeof
(
value
),
1
));
value
,
sizeof
(
value
),
1
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
...
@@ -235,7 +230,7 @@ void test_nghttp2_hd_inflate_indname_subst(void)
...
@@ -235,7 +230,7 @@ void test_nghttp2_hd_inflate_indname_subst(void)
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
inflater
.
hd_table
[
12
]
,
12
,
nv
.
value
,
nv
.
valuelen
,
nv
.
value
,
nv
.
valuelen
,
12
));
12
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
...
@@ -262,7 +257,7 @@ void test_nghttp2_hd_inflate_indname_subst_eviction(void)
...
@@ -262,7 +257,7 @@ void test_nghttp2_hd_inflate_indname_subst_eviction(void)
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
inflater
.
hd_table
[
2
]
,
2
,
value
,
sizeof
(
value
),
2
));
value
,
sizeof
(
value
),
2
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
...
@@ -293,7 +288,7 @@ void test_nghttp2_hd_inflate_indname_subst_eviction_neg(void)
...
@@ -293,7 +288,7 @@ void test_nghttp2_hd_inflate_indname_subst_eviction_neg(void)
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
nghttp2_hd_inflate_init
(
&
inflater
,
NGHTTP2_HD_SIDE_SERVER
);
/* Try to substitute index 0, but it will be evicted */
/* Try to substitute index 0, but it will be evicted */
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
CU_ASSERT
(
0
==
nghttp2_hd_emit_subst_indname_block
(
&
buf
,
&
buflen
,
&
offset
,
inflater
.
hd_table
[
2
]
,
2
,
value
,
sizeof
(
value
),
0
));
value
,
sizeof
(
value
),
0
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
1
==
nghttp2_hd_inflate_hd
(
&
inflater
,
&
resnva
,
buf
,
offset
));
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
CU_ASSERT
(
5
==
resnva
[
0
].
namelen
);
...
...
tests/nghttp2_session_test.c
View file @
ddd04e8c
...
@@ -316,6 +316,8 @@ void test_nghttp2_session_recv(void)
...
@@ -316,6 +316,8 @@ void test_nghttp2_session_recv(void)
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
&
frame
.
headers
,
&
frame
.
headers
,
&
session
->
hd_deflater
);
&
session
->
hd_deflater
);
nghttp2_hd_end_headers
(
&
session
->
hd_deflater
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
/* Send 1 byte per each read */
/* Send 1 byte per each read */
for
(
i
=
0
;
i
<
framelen
;
++
i
)
{
for
(
i
=
0
;
i
<
framelen
;
++
i
)
{
...
@@ -336,6 +338,8 @@ void test_nghttp2_session_recv(void)
...
@@ -336,6 +338,8 @@ void test_nghttp2_session_recv(void)
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
&
frame
.
headers
,
&
frame
.
headers
,
&
session
->
hd_deflater
);
&
session
->
hd_deflater
);
nghttp2_hd_end_headers
(
&
session
->
hd_deflater
);
nghttp2_frame_headers_free
(
&
frame
.
headers
);
nghttp2_frame_headers_free
(
&
frame
.
headers
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
...
@@ -395,6 +399,8 @@ void test_nghttp2_session_recv_invalid_stream_id(void)
...
@@ -395,6 +399,8 @@ void test_nghttp2_session_recv_invalid_stream_id(void)
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
&
frame
.
headers
,
&
frame
.
headers
,
&
session
->
hd_deflater
);
&
session
->
hd_deflater
);
nghttp2_hd_end_headers
(
&
session
->
hd_deflater
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
nghttp2_frame_headers_free
(
&
frame
.
headers
);
nghttp2_frame_headers_free
(
&
frame
.
headers
);
...
@@ -435,6 +441,8 @@ void test_nghttp2_session_recv_invalid_frame(void)
...
@@ -435,6 +441,8 @@ void test_nghttp2_session_recv_invalid_frame(void)
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
framelen
=
nghttp2_frame_pack_headers
(
&
framedata
,
&
framedatalen
,
&
frame
.
headers
,
&
frame
.
headers
,
&
session
->
hd_deflater
);
&
session
->
hd_deflater
);
nghttp2_hd_end_headers
(
&
session
->
hd_deflater
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
scripted_data_feed_init
(
&
df
,
framedata
,
framelen
);
CU_ASSERT
(
0
==
nghttp2_session_recv
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_recv
(
session
));
...
...
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