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
ef5d981a
Commit
ef5d981a
authored
Jan 17, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Simplify
parent
d5efab49
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
27 deletions
+21
-27
src/memchunk.h
src/memchunk.h
+1
-0
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+5
-8
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+1
-1
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+4
-4
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+9
-13
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+1
-1
No files found.
src/memchunk.h
View file @
ef5d981a
...
...
@@ -165,6 +165,7 @@ template <typename Memchunk> struct Memchunks {
return
append
(
s
,
N
-
1
);
}
size_t
append
(
const
std
::
string
&
s
)
{
return
append
(
s
.
c_str
(),
s
.
size
());
}
size_t
append
(
const
StringRef
&
s
)
{
return
append
(
s
.
c_str
(),
s
.
size
());
}
size_t
remove
(
void
*
dest
,
size_t
count
)
{
if
(
!
tail
||
count
==
0
)
{
return
0
;
...
...
src/shrpx_http2_session.cc
View file @
ef5d981a
...
...
@@ -334,18 +334,15 @@ int Http2Session::initiate_connection() {
conn_
.
set_ssl
(
ssl
);
}
const
char
*
sni_name
=
nullptr
;
if
(
!
get_config
()
->
backend_tls_sni_name
.
empty
())
{
sni_name
=
get_config
()
->
backend_tls_sni_name
.
c_str
();
}
else
{
sni_name
=
downstream_addr
.
host
.
c_str
();
}
StringRef
sni_name
=
!
get_config
()
->
backend_tls_sni_name
.
empty
()
?
get_config
()
->
backend_tls_sni_name
:
downstream_addr
.
host
;
if
(
sni_name
&&
!
util
::
numeric_host
(
sni_name
))
{
if
(
!
util
::
numeric_host
(
sni_name
.
c_str
()
))
{
// TLS extensions: SNI. There is no documentation about the return
// code for this function (actually this is macro wrapping SSL_ctrl
// at the time of this writing).
SSL_set_tlsext_host_name
(
conn_
.
tls
.
ssl
,
sni_name
);
SSL_set_tlsext_host_name
(
conn_
.
tls
.
ssl
,
sni_name
.
c_str
()
);
}
// If state_ == PROXY_CONNECTED, we has connected to the proxy
// using conn_.fd and tunnel has been established.
...
...
src/shrpx_http2_upstream.cc
View file @
ef5d981a
...
...
@@ -1365,7 +1365,7 @@ int Http2Upstream::error_reply(Downstream *downstream,
auto
html
=
http
::
create_error_html
(
status_code
);
resp
.
http_status
=
status_code
;
auto
body
=
downstream
->
get_response_buf
();
body
->
append
(
html
.
c_str
(),
html
.
size
()
);
body
->
append
(
html
);
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
nghttp2_data_provider
data_prd
;
...
...
src/shrpx_http_downstream_connection.cc
View file @
ef5d981a
...
...
@@ -238,14 +238,14 @@ int HttpDownstreamConnection::push_request_headers() {
buf
->
append
(
" "
);
if
(
connect_method
)
{
buf
->
append
(
authority
.
c_str
(),
authority
.
size
()
);
buf
->
append
(
authority
);
}
else
if
(
get_config
()
->
http2_proxy
||
get_config
()
->
client_proxy
)
{
// Construct absolute-form request target because we are going to
// send a request to a HTTP/1 proxy.
assert
(
!
req
.
scheme
.
empty
());
buf
->
append
(
req
.
scheme
);
buf
->
append
(
"://"
);
buf
->
append
(
authority
.
c_str
(),
authority
.
size
()
);
buf
->
append
(
authority
);
buf
->
append
(
req
.
path
);
}
else
if
(
req
.
method
==
HTTP_OPTIONS
&&
req
.
path
.
empty
())
{
// Server-wide OPTIONS
...
...
@@ -254,7 +254,7 @@ int HttpDownstreamConnection::push_request_headers() {
buf
->
append
(
req
.
path
);
}
buf
->
append
(
" HTTP/1.1
\r\n
Host: "
);
buf
->
append
(
authority
.
c_str
(),
authority
.
size
()
);
buf
->
append
(
authority
);
buf
->
append
(
"
\r\n
"
);
http2
::
build_http1_headers_from_headers
(
buf
,
req
.
fs
.
headers
());
...
...
@@ -402,7 +402,7 @@ int HttpDownstreamConnection::push_upload_data_chunk(const uint8_t *data,
if
(
chunked
)
{
auto
chunk_size_hex
=
util
::
utox
(
datalen
);
output
->
append
(
chunk_size_hex
.
c_str
(),
chunk_size_hex
.
size
()
);
output
->
append
(
chunk_size_hex
);
output
->
append
(
"
\r\n
"
);
}
...
...
src/shrpx_https_upstream.cc
View file @
ef5d981a
...
...
@@ -802,8 +802,7 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body,
if
(
!
resp
.
fs
.
header
(
http2
::
HD_SERVER
))
{
output
->
append
(
"Server: "
);
const
auto
&
server_name
=
get_config
()
->
server_name
;
output
->
append
(
server_name
.
c_str
(),
server_name
.
size
());
output
->
append
(
get_config
()
->
server_name
);
output
->
append
(
"
\r\n
"
);
}
...
...
@@ -838,21 +837,21 @@ void HttpsUpstream::error_reply(unsigned int status_code) {
output
->
append
(
"HTTP/1.1 "
);
auto
status_str
=
http2
::
get_status_string
(
status_code
);
output
->
append
(
status_str
.
c_str
(),
status_str
.
size
()
);
output
->
append
(
status_str
);
output
->
append
(
"
\r\n
Server: "
);
const
auto
&
server_name
=
get_config
()
->
server_name
;
output
->
append
(
server_name
.
c_str
(),
server_name
.
size
()
);
output
->
append
(
server_name
);
output
->
append
(
"
\r\n
Content-Length: "
);
auto
cl
=
util
::
utos
(
html
.
size
());
output
->
append
(
cl
.
c_str
(),
cl
.
size
()
);
output
->
append
(
cl
);
output
->
append
(
"
\r\n
Date: "
);
auto
lgconf
=
log_config
();
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
auto
&
date
=
lgconf
->
time_http_str
;
output
->
append
(
date
.
c_str
(),
date
.
size
()
);
output
->
append
(
date
);
output
->
append
(
"
\r\n
Content-Type: text/html; "
"charset=UTF-8
\r\n
Connection: close
\r\n\r\n
"
);
output
->
append
(
html
.
c_str
(),
html
.
size
()
);
output
->
append
(
html
);
downstream
->
response_sent_body_length
+=
html
.
size
();
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
...
...
@@ -1000,8 +999,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
if
(
!
get_config
()
->
http2_proxy
&&
!
get_config
()
->
client_proxy
)
{
buf
->
append
(
"Server: "
);
const
auto
&
server_name
=
get_config
()
->
server_name
;
buf
->
append
(
server_name
.
c_str
(),
server_name
.
size
());
buf
->
append
(
get_config
()
->
server_name
);
buf
->
append
(
"
\r\n
"
);
}
else
{
auto
server
=
resp
.
fs
.
header
(
http2
::
HD_SERVER
);
...
...
@@ -1054,10 +1052,8 @@ int HttpsUpstream::on_downstream_body(Downstream *downstream,
}
auto
output
=
downstream
->
get_response_buf
();
if
(
downstream
->
get_chunked_response
())
{
auto
chunk_size_hex
=
util
::
utox
(
len
);
chunk_size_hex
+=
"
\r\n
"
;
output
->
append
(
chunk_size_hex
.
c_str
(),
chunk_size_hex
.
size
());
output
->
append
(
util
::
utox
(
len
));
output
->
append
(
"
\r\n
"
);
}
output
->
append
(
data
,
len
);
...
...
src/shrpx_spdy_upstream.cc
View file @
ef5d981a
...
...
@@ -905,7 +905,7 @@ int SpdyUpstream::error_reply(Downstream *downstream,
auto
html
=
http
::
create_error_html
(
status_code
);
resp
.
http_status
=
status_code
;
auto
body
=
downstream
->
get_response_buf
();
body
->
append
(
html
.
c_str
(),
html
.
size
()
);
body
->
append
(
html
);
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
spdylay_data_provider
data_prd
;
...
...
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