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
00efa86f
Commit
00efa86f
authored
Jun 05, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add --add-request-header option
parent
43b36408
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
4 deletions
+33
-4
src/shrpx.cc
src/shrpx.cc
+11
-0
src/shrpx_config.cc
src/shrpx_config.cc
+7
-3
src/shrpx_config.h
src/shrpx_config.h
+2
-0
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+6
-1
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+7
-0
No files found.
src/shrpx.cc
View file @
00efa86f
...
...
@@ -1350,6 +1350,12 @@ HTTP:
HTTP/1.1 frontend. This option can be used multiple
times to specify multiple alternative services.
Example: --altsvc=h2,443
--add-request-header=<HEADER>
Specify additional header field to add to request header
set. This option just appends header field and won't
replace anything already set. This option can be used
several times to specify multiple header fields.
Example: --add-request-header="foo: bar"
--add-response-header=<HEADER>
Specify additional header field to add to response
header set. This option just appends header field and
...
...
@@ -1544,6 +1550,7 @@ int main(int argc, char **argv) {
{
SHRPX_OPT_NO_OCSP
,
no_argument
,
&
flag
,
79
},
{
SHRPX_OPT_HEADER_FIELD_BUFFER
,
required_argument
,
&
flag
,
80
},
{
SHRPX_OPT_MAX_HEADER_FIELDS
,
required_argument
,
&
flag
,
81
},
{
SHRPX_OPT_ADD_REQUEST_HEADER
,
required_argument
,
&
flag
,
82
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
...
...
@@ -1902,6 +1909,10 @@ int main(int argc, char **argv) {
// --max-header-fields
cmdcfgs
.
emplace_back
(
SHRPX_OPT_MAX_HEADER_FIELDS
,
optarg
);
break
;
case
82
:
// --add-request-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_REQUEST_HEADER
,
optarg
);
break
;
default:
break
;
}
...
...
src/shrpx_config.cc
View file @
00efa86f
...
...
@@ -997,14 +997,18 @@ int parse_config(const char *opt, const char *optarg) {
return
0
;
}
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_ADD_RESPONSE_HEADER
))
{
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_ADD_REQUEST_HEADER
)
||
util
::
strieq
(
opt
,
SHRPX_OPT_ADD_RESPONSE_HEADER
))
{
auto
p
=
parse_header
(
optarg
);
if
(
p
.
first
.
empty
())
{
LOG
(
ERROR
)
<<
opt
<<
": header field name is empty: "
<<
optarg
;
return
-
1
;
}
mod_config
()
->
add_response_headers
.
push_back
(
std
::
move
(
p
));
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_ADD_REQUEST_HEADER
))
{
mod_config
()
->
add_request_headers
.
push_back
(
std
::
move
(
p
));
}
else
{
mod_config
()
->
add_response_headers
.
push_back
(
std
::
move
(
p
));
}
return
0
;
}
...
...
src/shrpx_config.h
View file @
00efa86f
...
...
@@ -140,6 +140,7 @@ constexpr char SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING[] =
constexpr
char
SHRPX_OPT_FRONTEND_FRAME_DEBUG
[]
=
"frontend-frame-debug"
;
constexpr
char
SHRPX_OPT_PADDING
[]
=
"padding"
;
constexpr
char
SHRPX_OPT_ALTSVC
[]
=
"altsvc"
;
constexpr
char
SHRPX_OPT_ADD_REQUEST_HEADER
[]
=
"add-request-header"
;
constexpr
char
SHRPX_OPT_ADD_RESPONSE_HEADER
[]
=
"add-response-header"
;
constexpr
char
SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS
[]
=
"worker-frontend-connections"
;
...
...
@@ -220,6 +221,7 @@ struct Config {
// The list of (private key file, certificate file) pair
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
subcerts
;
std
::
vector
<
AltSvc
>
altsvcs
;
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
add_request_headers
;
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
add_response_headers
;
std
::
vector
<
unsigned
char
>
alpn_prefs
;
std
::
vector
<
LogFragment
>
accesslog_format
;
...
...
src/shrpx_http2_downstream_connection.cc
View file @
00efa86f
...
...
@@ -313,7 +313,8 @@ int Http2DownstreamConnection::push_request_headers() {
// 7. x-forwarded-proto (optional)
// 8. te (optional)
auto
nva
=
std
::
vector
<
nghttp2_nv
>
();
nva
.
reserve
(
nheader
+
8
+
cookies
.
size
());
nva
.
reserve
(
nheader
+
8
+
cookies
.
size
()
+
get_config
()
->
add_request_headers
.
size
());
std
::
string
via_value
;
std
::
string
xff_value
;
...
...
@@ -411,6 +412,10 @@ int Http2DownstreamConnection::push_request_headers() {
nva
.
push_back
(
http2
::
make_nv_ll
(
"te"
,
"trailers"
));
}
for
(
auto
&
p
:
get_config
()
->
add_request_headers
)
{
nva
.
push_back
(
http2
::
make_nv
(
p
.
first
,
p
.
second
));
}
if
(
LOG_ENABLED
(
INFO
))
{
std
::
stringstream
ss
;
for
(
auto
&
nv
:
nva
)
{
...
...
src/shrpx_http_downstream_connection.cc
View file @
00efa86f
...
...
@@ -366,6 +366,13 @@ int HttpDownstreamConnection::push_request_headers() {
hdrs
+=
"
\r\n
"
;
}
for
(
auto
&
p
:
get_config
()
->
add_request_headers
)
{
hdrs
+=
p
.
first
;
hdrs
+=
": "
;
hdrs
+=
p
.
second
;
hdrs
+=
"
\r\n
"
;
}
hdrs
+=
"
\r\n
"
;
if
(
LOG_ENABLED
(
INFO
))
{
const
char
*
hdrp
;
...
...
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