nghttpx: Add function to send trailer part in h1 frontend

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-08 17:32:38 +09:00
parent 991baf9e69
commit 42eeebc7f6
1 changed files with 10 additions and 1 deletions

View File

@ -780,7 +780,16 @@ int HttpsUpstream::on_downstream_body(Downstream *downstream,
int HttpsUpstream::on_downstream_body_complete(Downstream *downstream) {
if (downstream->get_chunked_response()) {
auto output = downstream->get_response_buf();
output->append("0\r\n\r\n");
auto &trailers = downstream->get_response_trailers();
if (trailers.empty()) {
output->append("0\r\n\r\n");
} else {
output->append("0\r\n");
std::string trailer_part;
http2::build_http1_headers_from_headers(trailer_part, trailers);
output->append(trailer_part.c_str(), trailer_part.size());
output->append("\r\n");
}
}
if (LOG_ENABLED(INFO)) {
DLOG(INFO, downstream) << "HTTP response completed";