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
4c55a234
Commit
4c55a234
authored
Mar 07, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp: Add --trailer optiont to send trailer header fields with -d option
parent
2f2a5351
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
src/nghttp.cc
src/nghttp.cc
+43
-0
src/nghttp.h
src/nghttp.h
+1
-0
No files found.
src/nghttp.cc
View file @
4c55a234
...
...
@@ -2110,6 +2110,7 @@ namespace {
ssize_t
file_read_callback
(
nghttp2_session
*
session
,
int32_t
stream_id
,
uint8_t
*
buf
,
size_t
length
,
uint32_t
*
data_flags
,
nghttp2_data_source
*
source
,
void
*
user_data
)
{
int
rv
;
auto
req
=
static_cast
<
Request
*>
(
nghttp2_session_get_stream_user_data
(
session
,
stream_id
));
assert
(
req
);
...
...
@@ -2126,6 +2127,18 @@ ssize_t file_read_callback(nghttp2_session *session, int32_t stream_id,
if
(
nread
==
0
)
{
*
data_flags
|=
NGHTTP2_DATA_FLAG_EOF
;
if
(
!
config
.
trailer
.
empty
())
{
*
data_flags
|=
NGHTTP2_DATA_FLAG_NO_END_STREAM
;
std
::
vector
<
nghttp2_nv
>
nva
;
nva
.
reserve
(
config
.
trailer
.
size
());
for
(
auto
&
kv
:
config
.
trailer
)
{
nva
.
push_back
(
http2
::
make_nv
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
));
}
rv
=
nghttp2_submit_trailer
(
session
,
stream_id
,
nva
.
data
(),
nva
.
size
());
if
(
rv
!=
0
)
{
*
data_flags
&=
~
NGHTTP2_DATA_FLAG_NO_END_STREAM
;
}
}
}
else
{
req
->
data_offset
+=
nread
;
}
...
...
@@ -2347,6 +2360,11 @@ Options:
-s, --stat Print statistics.
-H, --header=<HEADER>
Add a header to the requests. Example: -H':method: PUT'
--trailer=<HEADER>
Add a trailer header to the requests. <HEADER> must not
include pseudo header field (header field name starting
with ':'). To send trailer, one must use -d option to
send request body. Example: --trailer 'foo: bar'.
--cert=<CERT>
Use the specified client certificate file. The file
must be in PEM format.
...
...
@@ -2425,6 +2443,7 @@ int main(int argc, char **argv) {
{
"no-content-length"
,
no_argument
,
&
flag
,
6
},
{
"no-dep"
,
no_argument
,
&
flag
,
7
},
{
"dep-idle"
,
no_argument
,
&
flag
,
8
},
{
"trailer"
,
required_argument
,
&
flag
,
9
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
int
c
=
getopt_long
(
argc
,
argv
,
"M:Oab:c:d:gm:np:r:hH:vst:uw:W:"
,
...
...
@@ -2587,6 +2606,30 @@ int main(int argc, char **argv) {
// dep-idle option
config
.
dep_idle
=
true
;
break
;
case
9
:
{
// trailer option
auto
header
=
optarg
;
auto
value
=
strchr
(
optarg
,
':'
);
if
(
!
value
)
{
std
::
cerr
<<
"--trailer: invalid header: "
<<
optarg
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
*
value
=
0
;
value
++
;
while
(
isspace
(
*
value
))
{
value
++
;
}
if
(
*
value
==
0
)
{
// This could also be a valid case for suppressing a header
// similar to curl
std
::
cerr
<<
"--trailer: invalid header - value missing: "
<<
optarg
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
config
.
trailer
.
emplace_back
(
header
,
value
,
false
);
util
::
inp_strlower
(
config
.
trailer
.
back
().
name
);
break
;
}
}
break
;
default:
...
...
src/nghttp.h
View file @
4c55a234
...
...
@@ -58,6 +58,7 @@ struct Config {
~
Config
();
Headers
headers
;
Headers
trailer
;
std
::
string
certfile
;
std
::
string
keyfile
;
std
::
string
datafile
;
...
...
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