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
4be4d875
Commit
4be4d875
authored
May 04, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Log absolute URI for HTTP/2 or client proxy request
parent
1ab70771
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
5 deletions
+58
-5
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+51
-3
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+7
-2
No files found.
src/shrpx_client_handler.cc
View file @
4be4d875
...
...
@@ -690,15 +690,63 @@ void ClientHandler::start_immediate_shutdown() {
ev_timer_start
(
conn_
.
loop
,
&
reneg_shutdown_timer_
);
}
namespace
{
// Construct absolute request URI from |downstream|, mainly to log
// request URI for proxy request (HTTP/2 proxy or client proxy). This
// is mostly same routine found in
// HttpDownstreamConnection::push_request_headers(), but vastly
// simplified since we only care about absolute URI.
std
::
string
construct_absolute_request_uri
(
Downstream
*
downstream
)
{
const
char
*
authority
=
nullptr
,
*
host
=
nullptr
;
if
(
!
downstream
->
get_request_http2_authority
().
empty
())
{
authority
=
downstream
->
get_request_http2_authority
().
c_str
();
}
auto
h
=
downstream
->
get_request_header
(
http2
::
HD_HOST
);
if
(
h
)
{
host
=
h
->
value
.
c_str
();
}
if
(
!
authority
&&
!
host
)
{
return
downstream
->
get_request_path
();
}
std
::
string
uri
;
if
(
downstream
->
get_request_http2_scheme
().
empty
())
{
// this comes from HTTP/1 upstream without scheme. Just use http.
uri
+=
"http://"
;
}
else
{
uri
+=
downstream
->
get_request_http2_scheme
();
uri
+=
"://"
;
}
if
(
authority
)
{
uri
+=
authority
;
}
else
{
uri
+=
host
;
}
// Server-wide OPTIONS takes following form in proxy request:
//
// OPTIONS http://example.org HTTP/1.1
//
// Notice that no slash after authority. See
// http://tools.ietf.org/html/rfc7230#section-5.3.4
if
(
downstream
->
get_request_path
()
!=
"*"
)
{
uri
+=
downstream
->
get_request_path
();
}
return
uri
;
}
}
// namespace
void
ClientHandler
::
write_accesslog
(
Downstream
*
downstream
)
{
upstream_accesslog
(
get_config
()
->
accesslog_format
,
LogSpec
{
downstream
,
ipaddr_
.
c_str
(),
downstream
->
get_request_method
().
c_str
(),
downstream
->
get_request_path
().
empty
()
?
downstream
->
get_request_http2_authority
().
c_str
()
:
downstream
->
get_request_path
().
c_str
(),
(
downstream
->
get_request_method
()
!=
"CONNECT"
&&
(
get_config
()
->
http2_proxy
||
get_config
()
->
client_proxy
))
?
construct_absolute_request_uri
(
downstream
).
c_str
()
:
downstream
->
get_request_path
().
empty
()
?
downstream
->
get_request_http2_authority
().
c_str
()
:
downstream
->
get_request_path
().
c_str
(),
alpn_
.
c_str
(),
...
...
src/shrpx_https_upstream.cc
View file @
4be4d875
...
...
@@ -218,7 +218,12 @@ void rewrite_request_host_path_from_uri(Downstream *downstream, const char *uri,
path
+=
'?'
;
path
.
append
(
uri
+
fdata
.
off
,
fdata
.
len
);
}
downstream
->
set_request_path
(
path
);
downstream
->
set_request_path
(
std
::
move
(
path
));
if
(
get_config
()
->
http2_proxy
||
get_config
()
->
client_proxy
)
{
std
::
string
scheme
;
http2
::
copy_url_component
(
scheme
,
&
u
,
UF_SCHEMA
,
uri
);
downstream
->
set_request_http2_scheme
(
std
::
move
(
scheme
));
}
}
}
// namespace
...
...
@@ -275,7 +280,7 @@ int htp_hdrs_completecb(http_parser *htp) {
}
// checking UF_HOST could be redundant, but just in case ...
if
(
!
(
u
.
field_set
&
(
1
<<
UF_SCHEMA
))
||
!
(
u
.
field_set
&
(
1
<<
UF_HOST
)))
{
if
(
get_config
()
->
client_proxy
)
{
if
(
get_config
()
->
http2_proxy
||
get_config
()
->
client_proxy
)
{
// Request URI should be absolute-form for client proxy mode
return
-
1
;
}
...
...
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