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
d0fea96e
Commit
d0fea96e
authored
Aug 18, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow nonuniform buffer size in nghttp2_hd_deflate_hd_vec()
parent
b8883101
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
35 deletions
+28
-35
lib/includes/nghttp2/nghttp2.h
lib/includes/nghttp2/nghttp2.h
+6
-10
lib/nghttp2_buf.c
lib/nghttp2_buf.c
+4
-3
lib/nghttp2_buf.h
lib/nghttp2_buf.h
+5
-5
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+1
-15
tests/nghttp2_hd_test.c
tests/nghttp2_hd_test.c
+12
-2
No files found.
lib/includes/nghttp2/nghttp2.h
View file @
d0fea96e
...
...
@@ -4604,14 +4604,12 @@ nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
*
* Deflates the |nva|, which has the |nvlen| name/value pairs, into
* the |veclen| size of buf vector |vec|. The each size of buffer
* must be set in len field of :type:`nghttp2_vec`, and this function
* assumes all buffer size is equal. The application is responsible
* to make sure that this assumption holds. If one chunk is filled
* up, next chunk will be used. If |vec| is not large enough to store
* the deflated header block, this function fails with
* :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller should use
* `nghttp2_hd_deflate_bound()` to know the upper bound of buffer size
* required to deflate given header name/value pairs.
* must be set in len field of :type:`nghttp2_vec`. If and only if
* one chunk is filled up completely, next chunk will be used. If
* |vec| is not large enough to store the deflated header block, this
* function fails with :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller
* should use `nghttp2_hd_deflate_bound()` to know the upper bound of
* buffer size required to deflate given header name/value pairs.
*
* Once this function fails, subsequent call of this function always
* returns :enum:`NGHTTP2_ERR_HEADER_COMP`.
...
...
@@ -4627,8 +4625,6 @@ nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
* Deflation process has failed.
* :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`
* The provided |buflen| size is too small to hold the output.
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The size of each buffer in |nva| is not the same.
*/
NGHTTP2_EXTERN
ssize_t
nghttp2_hd_deflate_hd_vec
(
nghttp2_hd_deflater
*
deflater
,
const
nghttp2_vec
*
vec
,
...
...
lib/nghttp2_buf.c
View file @
d0fea96e
...
...
@@ -224,13 +224,13 @@ int nghttp2_bufs_wrap_init(nghttp2_bufs *bufs, uint8_t *begin, size_t len,
}
int
nghttp2_bufs_wrap_init2
(
nghttp2_bufs
*
bufs
,
const
nghttp2_vec
*
vec
,
size_t
veclen
,
size_t
chunklen
,
nghttp2_mem
*
mem
)
{
size_t
veclen
,
nghttp2_mem
*
mem
)
{
size_t
i
=
0
;
nghttp2_buf_chain
*
cur_chain
;
nghttp2_buf_chain
*
head_chain
;
nghttp2_buf_chain
**
dst_chain
=
&
head_chain
;
if
(
veclen
==
0
||
chunklen
==
0
)
{
if
(
veclen
==
0
)
{
return
nghttp2_bufs_wrap_init
(
bufs
,
NULL
,
0
,
mem
);
}
...
...
@@ -254,7 +254,8 @@ int nghttp2_bufs_wrap_init2(nghttp2_bufs *bufs, const nghttp2_vec *vec,
bufs
->
head
=
head_chain
;
bufs
->
cur
=
bufs
->
head
;
bufs
->
chunk_length
=
chunklen
;
/* We don't use chunk_length since no allocation is expected. */
bufs
->
chunk_length
=
0
;
bufs
->
chunk_used
=
veclen
;
bufs
->
max_chunk
=
veclen
;
bufs
->
chunk_keep
=
veclen
;
...
...
lib/nghttp2_buf.h
View file @
d0fea96e
...
...
@@ -212,10 +212,10 @@ int nghttp2_bufs_wrap_init(nghttp2_bufs *bufs, uint8_t *begin, size_t len,
/*
* Initializes |bufs| using supplied |veclen| size of buf vector
* |vec|
, assuming that each buffer has length |chunklen|. The buffer
*
size is fixed and no extra chunk buffer is allocated. In other
*
words, max_chunk = chunk_keep = |in_len|. To free the resourc
e
*
allocated for |bufs|, use
nghttp2_bufs_wrap_free().
* |vec|
. The number of buffers is fixed and no extra chunk buffer is
*
allocated. In other words, max_chunk = chunk_keep = |in_len|. To
*
free the resource allocated for |bufs|, us
e
* nghttp2_bufs_wrap_free().
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
...
...
@@ -224,7 +224,7 @@ int nghttp2_bufs_wrap_init(nghttp2_bufs *bufs, uint8_t *begin, size_t len,
* Out of memory.
*/
int
nghttp2_bufs_wrap_init2
(
nghttp2_bufs
*
bufs
,
const
nghttp2_vec
*
vec
,
size_t
veclen
,
size_t
chunklen
,
nghttp2_mem
*
mem
);
size_t
veclen
,
nghttp2_mem
*
mem
);
/*
* Frees any related resource to the |bufs|. This function does not
...
...
lib/nghttp2_hd.c
View file @
d0fea96e
...
...
@@ -1509,25 +1509,11 @@ ssize_t nghttp2_hd_deflate_hd_vec(nghttp2_hd_deflater *deflater,
nghttp2_bufs
bufs
;
int
rv
;
nghttp2_mem
*
mem
;
size_t
i
;
size_t
buflen
;
size_t
chunklen
;
if
(
veclen
==
0
)
{
chunklen
=
0
;
}
else
{
for
(
i
=
1
;
i
<
veclen
;
++
i
)
{
if
(
vec
[
0
].
len
!=
vec
[
i
].
len
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
}
chunklen
=
vec
[
0
].
len
;
}
mem
=
deflater
->
ctx
.
mem
;
rv
=
nghttp2_bufs_wrap_init2
(
&
bufs
,
vec
,
veclen
,
chunklen
,
mem
);
rv
=
nghttp2_bufs_wrap_init2
(
&
bufs
,
vec
,
veclen
,
mem
);
if
(
rv
!=
0
)
{
return
rv
;
...
...
tests/nghttp2_hd_test.c
View file @
d0fea96e
...
...
@@ -1352,14 +1352,24 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
vec
[
0
].
base
=
&
buf
[
0
];
vec
[
0
].
len
=
buflen
/
2
;
vec
[
1
].
base
=
&
buf
[
buflen
/
2
];
vec
[
1
].
len
=
(
buflen
/
2
)
-
1
;
vec
[
1
].
len
=
(
buflen
/
2
)
+
1
;
blocklen
=
nghttp2_hd_deflate_hd_vec
(
deflater
,
vec
,
2
,
nva
,
ARRLEN
(
nva
));
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
blocklen
);
CU_ASSERT
(
blocklen
>
0
);
nghttp2_bufs_wrap_init
(
&
bufs
,
buf
,
(
size_t
)
blocklen
,
mem
);
bufs
.
head
->
buf
.
last
+=
blocklen
;
CU_ASSERT
(
blocklen
==
inflate_hd
(
inflater
,
&
out
,
&
bufs
,
0
,
mem
));
CU_ASSERT
(
ARRLEN
(
nva
)
==
out
.
nvlen
);
assert_nv_equal
(
nva
,
out
.
nva
,
ARRLEN
(
nva
),
mem
);
nghttp2_bufs_wrap_free
(
&
bufs
);
nghttp2_hd_inflate_del
(
inflater
);
nghttp2_hd_deflate_del
(
deflater
);
nva_out_reset
(
&
out
,
mem
);
/* check the case where chunk size is 1 */
nghttp2_hd_deflate_new
(
&
deflater
,
4096
);
...
...
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