1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:37:43 +00:00

LibCore+LibHTTP+LibGfx: Switch to LibCompress

This commit removes the only 3rd party library (and its usages)
in serenity: puff, which is used for deflate decompression. and
replaces it with the existing original serenity implementation
in LibCompress. :^)
This commit is contained in:
Idan Horowitz 2021-03-03 23:54:07 +02:00 committed by Andreas Kling
parent 373a595c56
commit c12781a6a2
16 changed files with 31 additions and 1121 deletions

View file

@ -25,7 +25,7 @@
*/
#include <AK/Debug.h>
#include <LibCore/Gzip.h>
#include <LibCompress/Gzip.h>
#include <LibCore/TCPSocket.h>
#include <LibHTTP/HttpResponse.h>
#include <LibHTTP/Job.h>
@ -39,13 +39,13 @@ static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& c
dbgln_if(JOB_DEBUG, "Job::handle_content_encoding: buf has content_encoding={}", content_encoding);
if (content_encoding == "gzip") {
if (!Core::Gzip::is_compressed(buf)) {
if (!Compress::GzipDecompressor::is_likely_compressed(buf)) {
dbgln("Job::handle_content_encoding: buf is not gzip compressed!");
}
dbgln_if(JOB_DEBUG, "Job::handle_content_encoding: buf is gzip compressed!");
auto uncompressed = Core::Gzip::decompress(buf);
auto uncompressed = Compress::GzipDecompressor::decompress_all(buf);
if (!uncompressed.has_value()) {
dbgln("Job::handle_content_encoding: Gzip::decompress() failed. Returning original buffer.");
return buf;
@ -352,6 +352,7 @@ void Job::finish_up()
m_received_buffers.clear();
// For the time being, we cannot stream stuff with content-encoding set to _anything_.
// FIXME: LibCompress exposes a streaming interface, so this can be resolved
auto content_encoding = m_headers.get("Content-Encoding");
if (content_encoding.has_value()) {
flattened_buffer = handle_content_encoding(flattened_buffer, content_encoding.value());