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
a2afd393
Commit
a2afd393
authored
Jan 11, 2017
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Remove field from LogSpec which can be got from Downstream
parent
4e9098bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
79 deletions
+69
-79
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+3
-59
src/shrpx_log.cc
src/shrpx_log.cc
+66
-13
src/shrpx_log.h
src/shrpx_log.h
+0
-7
No files found.
src/shrpx_client_handler.cc
View file @
a2afd393
...
@@ -1190,50 +1190,10 @@ void ClientHandler::start_immediate_shutdown() {
...
@@ -1190,50 +1190,10 @@ void ClientHandler::start_immediate_shutdown() {
ev_timer_start
(
conn_
.
loop
,
&
reneg_shutdown_timer_
);
ev_timer_start
(
conn_
.
loop
,
&
reneg_shutdown_timer_
);
}
}
namespace
{
// Construct absolute request URI from |Request|, 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.
StringRef
construct_absolute_request_uri
(
BlockAllocator
&
balloc
,
const
Request
&
req
)
{
if
(
req
.
authority
.
empty
())
{
return
req
.
path
;
}
auto
len
=
req
.
authority
.
size
()
+
req
.
path
.
size
();
if
(
req
.
scheme
.
empty
())
{
len
+=
str_size
(
"http://"
);
}
else
{
len
+=
req
.
scheme
.
size
()
+
str_size
(
"://"
);
}
auto
iov
=
make_byte_ref
(
balloc
,
len
+
1
);
auto
p
=
iov
.
base
;
if
(
req
.
scheme
.
empty
())
{
// We may have to log the request which lacks scheme (e.g.,
// http/1.1 with origin form).
p
=
util
::
copy_lit
(
p
,
"http://"
);
}
else
{
p
=
std
::
copy
(
std
::
begin
(
req
.
scheme
),
std
::
end
(
req
.
scheme
),
p
);
p
=
util
::
copy_lit
(
p
,
"://"
);
}
p
=
std
::
copy
(
std
::
begin
(
req
.
authority
),
std
::
end
(
req
.
authority
),
p
);
p
=
std
::
copy
(
std
::
begin
(
req
.
path
),
std
::
end
(
req
.
path
),
p
);
*
p
=
'\0'
;
return
StringRef
{
iov
.
base
,
p
};
}
}
// namespace
void
ClientHandler
::
write_accesslog
(
Downstream
*
downstream
)
{
void
ClientHandler
::
write_accesslog
(
Downstream
*
downstream
)
{
nghttp2
::
ssl
::
TLSSessionInfo
tls_info
;
nghttp2
::
ssl
::
TLSSessionInfo
tls_info
;
auto
&
req
=
downstream
->
request
();
auto
&
req
=
downstream
->
request
();
const
auto
&
resp
=
downstream
->
response
();
auto
&
balloc
=
downstream
->
get_block_allocator
();
auto
config
=
get_config
();
auto
config
=
get_config
();
if
(
!
req
.
tstamp
)
{
if
(
!
req
.
tstamp
)
{
...
@@ -1245,26 +1205,10 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
...
@@ -1245,26 +1205,10 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
upstream_accesslog
(
upstream_accesslog
(
config
->
logging
.
access
.
format
,
config
->
logging
.
access
.
format
,
LogSpec
{
LogSpec
{
downstream
,
downstream
->
get_addr
(),
ipaddr_
,
downstream
,
ipaddr_
,
alpn_
,
http2
::
to_method_string
(
req
.
method
),
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
req
.
method
==
HTTP_CONNECT
?
StringRef
(
req
.
authority
)
:
config
->
http2_proxy
?
StringRef
(
construct_absolute_request_uri
(
balloc
,
req
))
:
req
.
path
.
empty
()
?
req
.
method
==
HTTP_OPTIONS
?
StringRef
::
from_lit
(
"*"
)
:
StringRef
::
from_lit
(
"-"
)
:
StringRef
(
req
.
path
),
alpn_
,
nghttp2
::
ssl
::
get_tls_session_info
(
&
tls_info
,
conn_
.
tls
.
ssl
),
downstream
->
get_request_start_time
(),
// request_start_time
std
::
chrono
::
high_resolution_clock
::
now
(),
// request_end_time
std
::
chrono
::
high_resolution_clock
::
now
(),
// request_end_time
port_
,
faddr_
->
port
,
config
->
pid
,
req
.
http_major
,
req
.
http_minor
,
resp
.
http_status
,
downstream
->
response_sent_body_length
,
port_
,
faddr_
->
port
,
config
->
pid
,
});
});
}
}
...
...
src/shrpx_log.cc
View file @
a2afd393
...
@@ -229,8 +229,47 @@ std::pair<OutputIterator, size_t> copy_hex_low(const uint8_t *src,
...
@@ -229,8 +229,47 @@ std::pair<OutputIterator, size_t> copy_hex_low(const uint8_t *src,
}
}
}
// namespace
}
// namespace
namespace
{
// Construct absolute request URI from |Request|, 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.
StringRef
construct_absolute_request_uri
(
BlockAllocator
&
balloc
,
const
Request
&
req
)
{
if
(
req
.
authority
.
empty
())
{
return
req
.
path
;
}
auto
len
=
req
.
authority
.
size
()
+
req
.
path
.
size
();
if
(
req
.
scheme
.
empty
())
{
len
+=
str_size
(
"http://"
);
}
else
{
len
+=
req
.
scheme
.
size
()
+
str_size
(
"://"
);
}
auto
iov
=
make_byte_ref
(
balloc
,
len
+
1
);
auto
p
=
iov
.
base
;
if
(
req
.
scheme
.
empty
())
{
// We may have to log the request which lacks scheme (e.g.,
// http/1.1 with origin form).
p
=
util
::
copy_lit
(
p
,
"http://"
);
}
else
{
p
=
std
::
copy
(
std
::
begin
(
req
.
scheme
),
std
::
end
(
req
.
scheme
),
p
);
p
=
util
::
copy_lit
(
p
,
"://"
);
}
p
=
std
::
copy
(
std
::
begin
(
req
.
authority
),
std
::
end
(
req
.
authority
),
p
);
p
=
std
::
copy
(
std
::
begin
(
req
.
path
),
std
::
end
(
req
.
path
),
p
);
*
p
=
'\0'
;
return
StringRef
{
iov
.
base
,
p
};
}
}
// namespace
void
upstream_accesslog
(
const
std
::
vector
<
LogFragment
>
&
lfv
,
void
upstream_accesslog
(
const
std
::
vector
<
LogFragment
>
&
lfv
,
const
LogSpec
&
lgsp
)
{
const
LogSpec
&
lgsp
)
{
auto
config
=
get_config
();
auto
lgconf
=
log_config
();
auto
lgconf
=
log_config
();
auto
&
accessconf
=
get_config
()
->
logging
.
access
;
auto
&
accessconf
=
get_config
()
->
logging
.
access
;
...
@@ -243,7 +282,21 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
...
@@ -243,7 +282,21 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
auto
downstream
=
lgsp
.
downstream
;
auto
downstream
=
lgsp
.
downstream
;
const
auto
&
req
=
downstream
->
request
();
const
auto
&
req
=
downstream
->
request
();
const
auto
&
resp
=
downstream
->
response
();
const
auto
&
tstamp
=
req
.
tstamp
;
const
auto
&
tstamp
=
req
.
tstamp
;
auto
&
balloc
=
downstream
->
get_block_allocator
();
auto
downstream_addr
=
downstream
->
get_addr
();
auto
method
=
http2
::
to_method_string
(
req
.
method
);
auto
path
=
req
.
method
==
HTTP_CONNECT
?
req
.
authority
:
config
->
http2_proxy
?
construct_absolute_request_uri
(
balloc
,
req
)
:
req
.
path
.
empty
()
?
req
.
method
==
HTTP_OPTIONS
?
StringRef
::
from_lit
(
"*"
)
:
StringRef
::
from_lit
(
"-"
)
:
req
.
path
;
auto
p
=
buf
;
auto
p
=
buf
;
auto
avail
=
sizeof
(
buf
)
-
2
;
auto
avail
=
sizeof
(
buf
)
-
2
;
...
@@ -263,21 +316,22 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
...
@@ -263,21 +316,22 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
avail
)
=
copy
(
tstamp
->
time_iso8601
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
tstamp
->
time_iso8601
,
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_REQUEST
:
case
SHRPX_LOGF_REQUEST
:
std
::
tie
(
p
,
avail
)
=
copy
(
lgsp
.
method
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
method
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
" "
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
" "
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
lgsp
.
path
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
path
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
" HTTP/"
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
" HTTP/"
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
lgsp
.
major
),
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
req
.
http_
major
),
avail
,
p
);
if
(
lgsp
.
major
<
2
)
{
if
(
req
.
http_
major
<
2
)
{
std
::
tie
(
p
,
avail
)
=
copy_l
(
"."
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
"."
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
lgsp
.
minor
),
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
req
.
http_
minor
),
avail
,
p
);
}
}
break
;
break
;
case
SHRPX_LOGF_STATUS
:
case
SHRPX_LOGF_STATUS
:
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
lgsp
.
status
),
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
resp
.
http_
status
),
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_BODY_BYTES_SENT
:
case
SHRPX_LOGF_BODY_BYTES_SENT
:
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
lgsp
.
body_bytes_sent
),
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
downstream
->
response_sent_body_length
),
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_HTTP
:
{
case
SHRPX_LOGF_HTTP
:
{
auto
hd
=
req
.
fs
.
header
(
lf
.
value
);
auto
hd
=
req
.
fs
.
header
(
lf
.
value
);
...
@@ -307,7 +361,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
...
@@ -307,7 +361,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
break
;
break
;
case
SHRPX_LOGF_REQUEST_TIME
:
{
case
SHRPX_LOGF_REQUEST_TIME
:
{
auto
t
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
auto
t
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
lgsp
.
request_end_time
-
lgsp
.
request_start_time
)
lgsp
.
request_end_time
-
downstream
->
get_request_start_time
()
)
.
count
();
.
count
();
auto
frac
=
util
::
utos
(
t
%
1000
);
auto
frac
=
util
::
utos
(
t
%
1000
);
...
@@ -358,19 +412,18 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
...
@@ -358,19 +412,18 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
copy_l
(
lgsp
.
tls_info
->
session_reused
?
"r"
:
"."
,
avail
,
p
);
copy_l
(
lgsp
.
tls_info
->
session_reused
?
"r"
:
"."
,
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_BACKEND_HOST
:
case
SHRPX_LOGF_BACKEND_HOST
:
if
(
!
lgsp
.
downstream_addr
)
{
if
(
!
downstream_addr
)
{
std
::
tie
(
p
,
avail
)
=
copy_l
(
"-"
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
"-"
,
avail
,
p
);
break
;
break
;
}
}
std
::
tie
(
p
,
avail
)
=
copy
(
lgsp
.
downstream_addr
->
host
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy
(
downstream_addr
->
host
,
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_BACKEND_PORT
:
case
SHRPX_LOGF_BACKEND_PORT
:
if
(
!
lgsp
.
downstream_addr
)
{
if
(
!
downstream_addr
)
{
std
::
tie
(
p
,
avail
)
=
copy_l
(
"-"
,
avail
,
p
);
std
::
tie
(
p
,
avail
)
=
copy_l
(
"-"
,
avail
,
p
);
break
;
break
;
}
}
std
::
tie
(
p
,
avail
)
=
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
downstream_addr
->
port
),
avail
,
p
);
copy
(
util
::
utos
(
lgsp
.
downstream_addr
->
port
),
avail
,
p
);
break
;
break
;
case
SHRPX_LOGF_NONE
:
case
SHRPX_LOGF_NONE
:
break
;
break
;
...
...
src/shrpx_log.h
View file @
a2afd393
...
@@ -145,17 +145,10 @@ struct LogFragment {
...
@@ -145,17 +145,10 @@ struct LogFragment {
struct
LogSpec
{
struct
LogSpec
{
Downstream
*
downstream
;
Downstream
*
downstream
;
const
DownstreamAddr
*
downstream_addr
;
StringRef
remote_addr
;
StringRef
remote_addr
;
StringRef
method
;
StringRef
path
;
StringRef
alpn
;
StringRef
alpn
;
const
nghttp2
::
ssl
::
TLSSessionInfo
*
tls_info
;
const
nghttp2
::
ssl
::
TLSSessionInfo
*
tls_info
;
std
::
chrono
::
high_resolution_clock
::
time_point
request_start_time
;
std
::
chrono
::
high_resolution_clock
::
time_point
request_end_time
;
std
::
chrono
::
high_resolution_clock
::
time_point
request_end_time
;
int
major
,
minor
;
unsigned
int
status
;
int64_t
body_bytes_sent
;
StringRef
remote_port
;
StringRef
remote_port
;
uint16_t
server_port
;
uint16_t
server_port
;
pid_t
pid
;
pid_t
pid
;
...
...
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