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
d16ff1f5
Commit
d16ff1f5
authored
Jan 17, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use StringAdaptor for Config::server_name
parent
2c7ed01f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
13 deletions
+18
-13
src/shrpx.cc
src/shrpx.cc
+1
-1
src/shrpx_config.h
src/shrpx_config.h
+1
-1
src/shrpx_http.cc
src/shrpx_http.cc
+2
-1
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+3
-3
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+6
-4
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+3
-3
src/template.h
src/template.h
+2
-0
No files found.
src/shrpx.cc
View file @
d16ff1f5
...
...
@@ -1039,7 +1039,7 @@ void fill_default_config() {
namespace
{
void
print_version
(
std
::
ostream
&
out
)
{
out
<<
get_config
()
->
server_name
<<
std
::
endl
;
out
<<
get_config
()
->
server_name
.
c_str
()
<<
std
::
endl
;
}
}
// namespace
...
...
src/shrpx_config.h
View file @
d16ff1f5
...
...
@@ -311,6 +311,7 @@ struct Config {
// string is provided.
std
::
string
forwarded_for_obfuscated
;
std
::
string
backend_tls_sni_name
;
StringAdaptor
server_name
;
std
::
chrono
::
seconds
tls_session_timeout
;
ev_tstamp
http2_upstream_read_timeout
;
ev_tstamp
upstream_read_timeout
;
...
...
@@ -363,7 +364,6 @@ struct Config {
nghttp2_option
*
http2_option
;
nghttp2_option
*
http2_client_option
;
const
EVP_CIPHER
*
tls_ticket_key_cipher
;
const
char
*
server_name
;
char
**
original_argv
;
char
**
argv
;
char
*
cwd
;
...
...
src/shrpx_http.cc
View file @
d16ff1f5
...
...
@@ -44,7 +44,8 @@ std::string create_error_html(unsigned int status_code) {
res
+=
"</title><body><h1>"
;
res
+=
status
;
res
+=
"</h1><footer>"
;
res
+=
get_config
()
->
server_name
;
const
auto
&
server_name
=
get_config
()
->
server_name
;
res
.
append
(
server_name
.
c_str
(),
server_name
.
size
());
res
+=
" at port "
;
res
+=
util
::
utos
(
get_config
()
->
port
);
res
+=
"</footer></body></html>"
;
...
...
src/shrpx_http2_upstream.cc
View file @
d16ff1f5
...
...
@@ -1337,7 +1337,7 @@ int Http2Upstream::send_reply(Downstream *downstream, const uint8_t *body,
if
(
!
resp
.
fs
.
header
(
http2
::
HD_SERVER
))
{
nva
.
push_back
(
http2
::
make_nv_l
c
_nocopy
(
"server"
,
get_config
()
->
server_name
));
http2
::
make_nv_l
s
_nocopy
(
"server"
,
get_config
()
->
server_name
));
}
rv
=
nghttp2_submit_response
(
session_
,
downstream
->
get_stream_id
(),
...
...
@@ -1386,7 +1386,7 @@ int Http2Upstream::error_reply(Downstream *downstream,
:
http2
::
make_nv_ls
(
":status"
,
(
status_code_str
=
util
::
utos
(
status_code
))),
http2
::
make_nv_ll
(
"content-type"
,
"text/html; charset=UTF-8"
),
http2
::
make_nv_l
c
_nocopy
(
"server"
,
get_config
()
->
server_name
),
http2
::
make_nv_l
s
_nocopy
(
"server"
,
get_config
()
->
server_name
),
http2
::
make_nv_ls
(
"content-length"
,
content_length
),
http2
::
make_nv_ls
(
"date"
,
lgconf
->
time_http_str
));
...
...
@@ -1507,7 +1507,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
if
(
!
get_config
()
->
http2_proxy
&&
!
get_config
()
->
client_proxy
)
{
nva
.
push_back
(
http2
::
make_nv_l
c
_nocopy
(
"server"
,
get_config
()
->
server_name
));
http2
::
make_nv_l
s
_nocopy
(
"server"
,
get_config
()
->
server_name
));
}
else
{
auto
server
=
resp
.
fs
.
header
(
http2
::
HD_SERVER
);
if
(
server
)
{
...
...
src/shrpx_https_upstream.cc
View file @
d16ff1f5
...
...
@@ -802,8 +802,8 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body,
if
(
!
resp
.
fs
.
header
(
http2
::
HD_SERVER
))
{
output
->
append
(
"Server: "
);
output
->
append
(
get_config
()
->
server_name
,
strlen
(
get_config
()
->
server_name
));
const
auto
&
server_name
=
get_config
()
->
server_name
;
output
->
append
(
server_name
.
c_str
(),
server_name
.
size
(
));
output
->
append
(
"
\r\n
"
);
}
...
...
@@ -840,7 +840,8 @@ void HttpsUpstream::error_reply(unsigned int status_code) {
auto
status_str
=
http2
::
get_status_string
(
status_code
);
output
->
append
(
status_str
.
c_str
(),
status_str
.
size
());
output
->
append
(
"
\r\n
Server: "
);
output
->
append
(
get_config
()
->
server_name
,
strlen
(
get_config
()
->
server_name
));
const
auto
&
server_name
=
get_config
()
->
server_name
;
output
->
append
(
server_name
.
c_str
(),
server_name
.
size
());
output
->
append
(
"
\r\n
Content-Length: "
);
auto
cl
=
util
::
utos
(
html
.
size
());
output
->
append
(
cl
.
c_str
(),
cl
.
size
());
...
...
@@ -999,7 +1000,8 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
if
(
!
get_config
()
->
http2_proxy
&&
!
get_config
()
->
client_proxy
)
{
buf
->
append
(
"Server: "
);
buf
->
append
(
get_config
()
->
server_name
,
strlen
(
get_config
()
->
server_name
));
const
auto
&
server_name
=
get_config
()
->
server_name
;
buf
->
append
(
server_name
.
c_str
(),
server_name
.
size
());
buf
->
append
(
"
\r\n
"
);
}
else
{
auto
server
=
resp
.
fs
.
header
(
http2
::
HD_SERVER
);
...
...
src/shrpx_spdy_upstream.cc
View file @
d16ff1f5
...
...
@@ -875,7 +875,7 @@ int SpdyUpstream::send_reply(Downstream *downstream, const uint8_t *body,
if
(
!
resp
.
fs
.
header
(
http2
::
HD_SERVER
))
{
nva
.
push_back
(
"server"
);
nva
.
push_back
(
get_config
()
->
server_name
);
nva
.
push_back
(
get_config
()
->
server_name
.
c_str
()
);
}
nva
.
push_back
(
nullptr
);
...
...
@@ -919,7 +919,7 @@ int SpdyUpstream::error_reply(Downstream *downstream,
std
::
string
status_string
=
http2
::
get_status_string
(
status_code
);
const
char
*
nv
[]
=
{
":status"
,
status_string
.
c_str
(),
":version"
,
"http/1.1"
,
"content-type"
,
"text/html; charset=UTF-8"
,
"server"
,
get_config
()
->
server_name
,
"content-length"
,
get_config
()
->
server_name
.
c_str
()
,
"content-length"
,
content_length
.
c_str
(),
"date"
,
lgconf
->
time_http_str
.
c_str
(),
nullptr
};
...
...
@@ -1034,7 +1034,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
if
(
!
get_config
()
->
http2_proxy
&&
!
get_config
()
->
client_proxy
)
{
nv
[
hdidx
++
]
=
"server"
;
nv
[
hdidx
++
]
=
get_config
()
->
server_name
;
nv
[
hdidx
++
]
=
get_config
()
->
server_name
.
c_str
()
;
}
else
{
auto
server
=
resp
.
fs
.
header
(
http2
::
HD_SERVER
);
if
(
server
)
{
...
...
src/template.h
View file @
d16ff1f5
...
...
@@ -227,9 +227,11 @@ struct VString {
};
struct
StringAdaptor
{
StringAdaptor
()
:
base
(
""
),
len
(
0
)
{}
template
<
typename
T
>
StringAdaptor
(
const
T
&
s
)
:
base
(
s
.
c_str
()),
len
(
s
.
size
())
{}
StringAdaptor
(
const
char
*
s
)
:
base
(
s
),
len
(
strlen
(
s
))
{}
const
char
*
c_str
()
const
{
return
base
;
}
size_t
size
()
const
{
return
len
;
}
...
...
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