Compress status responses. spdy clients must support gzip decoding.

This commit is contained in:
Jim Morrison 2012-04-11 13:15:56 -07:00
parent f74bfae451
commit 9638dc8b0a
1 changed files with 7 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include <iostream> #include <iostream>
#include <openssl/err.h> #include <openssl/err.h>
#include <zlib.h>
#include "spdylay_ssl.h" #include "spdylay_ssl.h"
#include "uri.h" #include "uri.h"
@ -435,14 +436,18 @@ void prepare_status_response(Request *req, SpdyEventHandler *hd,
<< "</address>" << "</address>"
<< "</body></html>"; << "</body></html>";
std::string body = ss.str(); std::string body = ss.str();
write(pipefd[1], body.c_str(), body.size()); gzFile write_fd = gzdopen(pipefd[1], "w");
gzwrite(write_fd, body.c_str(), body.size());
gzclose(write_fd);
close(pipefd[1]); close(pipefd[1]);
req->file = pipefd[0]; req->file = pipefd[0];
spdylay_data_provider data_prd; spdylay_data_provider data_prd;
data_prd.source.fd = pipefd[0]; data_prd.source.fd = pipefd[0];
data_prd.read_callback = file_read_callback; data_prd.read_callback = file_read_callback;
hd->submit_file_response(status, req->stream_id, 0, body.size(), &data_prd); std::vector<std::pair<std::string, std::string> > headers;
headers.push_back(std::make_pair("content-encoding", "gzip"));
hd->submit_response(status, req->stream_id, headers, &data_prd);
} }
} }
} // namespace } // namespace