From 9638dc8b0a77215d48b21572d69e12bf7b74c628 Mon Sep 17 00:00:00 2001 From: Jim Morrison Date: Wed, 11 Apr 2012 13:15:56 -0700 Subject: [PATCH] Compress status responses. spdy clients must support gzip decoding. --- examples/SpdyServer.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/SpdyServer.cc b/examples/SpdyServer.cc index fe113b42..269e64c8 100644 --- a/examples/SpdyServer.cc +++ b/examples/SpdyServer.cc @@ -37,6 +37,7 @@ #include #include +#include #include "spdylay_ssl.h" #include "uri.h" @@ -435,14 +436,18 @@ void prepare_status_response(Request *req, SpdyEventHandler *hd, << "" << ""; 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]); req->file = pipefd[0]; spdylay_data_provider data_prd; data_prd.source.fd = pipefd[0]; data_prd.read_callback = file_read_callback; - hd->submit_file_response(status, req->stream_id, 0, body.size(), &data_prd); + std::vector > headers; + headers.push_back(std::make_pair("content-encoding", "gzip")); + hd->submit_response(status, req->stream_id, headers, &data_prd); } } } // namespace