| 189 | } |
| 190 | |
| 191 | bool Compress(TData& data, const TString& compressionScheme) { |
| 192 | if (compressionScheme == "gzip" && data.size() > 23) { // there is no string less than 24 bytes long that might be compressed with gzip |
| 193 | try { |
| 194 | TData gzipped(data.size()); |
| 195 | TMemoryOutput out(gzipped.data(), gzipped.size()); |
| 196 | TZLibCompress c(&out, ZLib::GZip); |
| 197 | c.Write(data.data(), data.size()); |
| 198 | c.Finish(); |
| 199 | gzipped.resize(out.Buf() - gzipped.data()); |
| 200 | data.swap(gzipped); |
| 201 | return true; |
| 202 | } catch (yexception&) { |
| 203 | // gzipped data occupies more space than original data |
| 204 | } |
| 205 | } |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | class THttpRequestBuffers: public NAsio::TTcpSocket::IBuffers { |
| 210 | public: |
no test coverage detected