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
5a8cf943
Commit
5a8cf943
authored
Jan 14, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Refactor Downstream::response_sent_bodylen_
parent
3218c160
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
25 deletions
+13
-25
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+1
-1
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+4
-12
src/shrpx_downstream.h
src/shrpx_downstream.h
+3
-5
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+1
-3
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+3
-3
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+1
-1
No files found.
src/shrpx_client_handler.cc
View file @
5a8cf943
...
...
@@ -834,7 +834,7 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
std
::
chrono
::
high_resolution_clock
::
now
(),
// request_end_time
req
.
http_major
,
req
.
http_minor
,
resp
.
http_status
,
downstream
->
get_response_sent_bodylen
()
,
port_
.
c_str
(),
downstream
->
response_sent_body_length
,
port_
.
c_str
(),
get_config
()
->
port
,
get_config
()
->
pid
,
});
}
...
...
src/shrpx_downstream.cc
View file @
5a8cf943
...
...
@@ -113,11 +113,11 @@ void downstream_wtimeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
// upstream could be nullptr for unittests
Downstream
::
Downstream
(
Upstream
*
upstream
,
MemchunkPool
*
mcpool
,
int32_t
stream_id
,
int32_t
priority
)
:
dlnext
(
nullptr
),
dlprev
(
nullptr
),
:
dlnext
(
nullptr
),
dlprev
(
nullptr
),
response_sent_body_length
(
0
),
request_start_time_
(
std
::
chrono
::
high_resolution_clock
::
now
()),
request_buf_
(
mcpool
),
response_buf_
(
mcpool
),
response_sent_bodylen_
(
0
),
upstream_
(
upstream
),
blocked_link_
(
nullptr
),
num_retry_
(
0
),
stream_id_
(
stream_id
),
priority_
(
priority
),
downstream_stream_id_
(
-
1
),
request_buf_
(
mcpool
),
response_buf_
(
mcpool
),
upstream_
(
upstream
),
blocked_link_
(
nullptr
),
num_retry_
(
0
),
stream_id_
(
stream_id
),
priority_
(
priority
),
downstream_stream_id_
(
-
1
),
response_rst_stream_error_code_
(
NGHTTP2_NO_ERROR
),
request_state_
(
INITIAL
),
response_state_
(
INITIAL
),
dispatch_state_
(
DISPATCH_NONE
),
upgraded_
(
false
),
chunked_request_
(
false
),
...
...
@@ -627,14 +627,6 @@ bool Downstream::response_buf_full() {
}
}
void
Downstream
::
add_response_sent_bodylen
(
size_t
amount
)
{
response_sent_bodylen_
+=
amount
;
}
int64_t
Downstream
::
get_response_sent_bodylen
()
const
{
return
response_sent_bodylen_
;
}
bool
Downstream
::
validate_request_recv_body_length
()
const
{
if
(
req_
.
fs
.
content_length
==
-
1
)
{
return
true
;
...
...
src/shrpx_downstream.h
View file @
5a8cf943
...
...
@@ -297,8 +297,6 @@ public:
int
get_response_state
()
const
;
DefaultMemchunks
*
get_response_buf
();
bool
response_buf_full
();
void
add_response_sent_bodylen
(
size_t
amount
);
int64_t
get_response_sent_bodylen
()
const
;
// Validates that received response body length and content-length
// matches.
bool
validate_response_recv_body_length
()
const
;
...
...
@@ -381,6 +379,9 @@ public:
Downstream
*
dlnext
,
*
dlprev
;
// the length of response body sent to upstream client
int64_t
response_sent_body_length
;
private:
Request
req_
;
Response
resp_
;
...
...
@@ -401,9 +402,6 @@ private:
ev_timer
downstream_rtimer_
;
ev_timer
downstream_wtimer_
;
// the length of response body sent to upstream client
int64_t
response_sent_bodylen_
;
Upstream
*
upstream_
;
std
::
unique_ptr
<
DownstreamConnection
>
dconn_
;
...
...
src/shrpx_http2_upstream.cc
View file @
5a8cf943
...
...
@@ -728,9 +728,7 @@ int send_data_callback(nghttp2_session *session, nghttp2_frame *frame,
// We have to add length here, so that we can log this amount of
// data transferred.
if
(
length
>
0
)
{
downstream
->
add_response_sent_bodylen
(
length
);
}
downstream
->
response_sent_body_length
+=
length
;
return
(
nwrite
<
length
||
npadwrite
<
padlen
)
?
NGHTTP2_ERR_PAUSE
:
0
;
}
...
...
src/shrpx_https_upstream.cc
View file @
5a8cf943
...
...
@@ -799,7 +799,7 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body,
output
->
append
(
body
,
bodylen
);
downstream
->
add_response_sent_bodylen
(
bodylen
)
;
downstream
->
response_sent_body_length
+=
bodylen
;
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
return
0
;
...
...
@@ -842,7 +842,7 @@ void HttpsUpstream::error_reply(unsigned int status_code) {
"charset=UTF-8
\r\n
Connection: close
\r\n\r\n
"
);
output
->
append
(
html
.
c_str
(),
html
.
size
());
downstream
->
add_response_sent_bodylen
(
html
.
size
()
);
downstream
->
response_sent_body_length
+=
html
.
size
(
);
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
}
...
...
@@ -1048,7 +1048,7 @@ int HttpsUpstream::on_downstream_body(Downstream *downstream,
}
output
->
append
(
data
,
len
);
downstream
->
add_response_sent_bodylen
(
len
)
;
downstream
->
response_sent_body_length
+=
len
;
if
(
downstream
->
get_chunked_response
())
{
output
->
append
(
"
\r\n
"
);
...
...
src/shrpx_spdy_upstream.cc
View file @
5a8cf943
...
...
@@ -804,7 +804,7 @@ ssize_t spdy_data_read_callback(spdylay_session *session, int32_t stream_id,
}
if
(
nread
>
0
)
{
downstream
->
add_response_sent_bodylen
(
nread
)
;
downstream
->
response_sent_body_length
+=
nread
;
}
return
nread
;
...
...
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