Skip to content
Snippets Groups Projects
Commit 27126a2e authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Fallback to uncompressed parsing, if decompression fails

Some reverse proxies have bugs or a misconfigured and return
uncompressed bodies with a compression header (i.e. some versions of
caddy, if you enable compression in synapse). This prevents nheko
breaking in those cases.
parent 62bab2b2
No related branches found
No related tags found
No related merge requests found
......@@ -95,16 +95,30 @@ std::string
mtx::client::utils::decompress(const boost::iostreams::array_source &src,
const std::string &type) noexcept
{
try {
boost::iostreams::filtering_istream is;
is.set_auto_close(true);
std::stringstream decompressed;
if (type == "deflate")
is.push(boost::iostreams::zlib_decompressor{});
else if (type == "gzip")
is.push(boost::iostreams::gzip_decompressor{});
is.push(src);
boost::iostreams::copy(is, decompressed);
return decompressed.str();
} catch (boost::iostreams::gzip_error &) {
} catch (boost::iostreams::zlib_error &) {
}
boost::iostreams::filtering_istream is;
is.set_auto_close(true);
std::stringstream decompressed;
if (type == "deflate")
is.push(boost::iostreams::zlib_decompressor{});
else if (type == "gzip")
is.push(boost::iostreams::gzip_decompressor{});
is.push(src);
boost::iostreams::copy(is, decompressed);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment