nghttpx: Avoid 0-length DATA in HTTP/2 upstream

This commit is contained in:
Tatsuhiro Tsujikawa 2014-11-22 17:32:59 +09:00
parent bded1d1115
commit 1a09cef0ef
1 changed files with 6 additions and 4 deletions

View File

@ -1101,7 +1101,9 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
} }
if(nread == 0 && auto body_empty = evbuffer_get_length(body) == 0;
if(body_empty &&
downstream->get_response_state() == Downstream::MSG_COMPLETE) { downstream->get_response_state() == Downstream::MSG_COMPLETE) {
*data_flags |= NGHTTP2_DATA_FLAG_EOF; *data_flags |= NGHTTP2_DATA_FLAG_EOF;
@ -1121,10 +1123,10 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
} }
} }
if(evbuffer_get_length(body) > 0) { if(body_empty) {
downstream->reset_upstream_wtimer();
} else {
downstream->disable_upstream_wtimer(); downstream->disable_upstream_wtimer();
} else {
downstream->reset_upstream_wtimer();
} }
if(nread > 0 && downstream->resume_read(SHRPX_NO_BUFFER, nread) != 0) { if(nread > 0 && downstream->resume_read(SHRPX_NO_BUFFER, nread) != 0) {