mirror of
https://github.com/moparisthebest/spdylay
synced 2024-12-22 15:48:53 -05:00
Compress status responses. spdy clients must support gzip decoding.
This commit is contained in:
parent
f74bfae451
commit
9638dc8b0a
@ -37,6 +37,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "spdylay_ssl.h"
|
||||
#include "uri.h"
|
||||
@ -435,14 +436,18 @@ void prepare_status_response(Request *req, SpdyEventHandler *hd,
|
||||
<< "</address>"
|
||||
<< "</body></html>";
|
||||
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<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
|
||||
|
Loading…
Reference in New Issue
Block a user