# oatpp-zlib **Repository Path**: mirrors_oatpp/oatpp-zlib ## Basic Information - **Project Name**: oatpp-zlib - **Description**: Module oatpp-zlib provides functionality for compressing/decompressing content with deflate and gzip. Supports both "Simple" and "Async" oatpp APIs. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-26 - **Last Updated**: 2026-02-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oatpp-zlib [![Build Status](https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.oatpp-zlib?branchName=master)](https://dev.azure.com/lganzzzo/lganzzzo/_build/latest?definitionId=23&branchName=master) Module `oatpp-zlib` provides functionality for compressing/decompressing content with `deflate` and `gzip`. Supports both "Simple" and "Async" oatpp APIs. See more: - [Oat++ Website](https://oatpp.io/) - [Oat++ Github Repository](https://github.com/oatpp/oatpp) ## How To Build ### Requires - ZLib installed. #### Install ZLib ```bash sudo apt-get install zlib1g-dev ``` ### Install oatpp-zlib Clone this repository. In the root of the repository run: ```bash mkdir build && cd build cmake .. make install ``` ## APIs ### Automatically Compress Served Content Configure `server::ConnectionHandler` in `AppComponent.hpp`. ```cpp #include "oatpp-zlib/EncoderProvider.hpp" ... OATPP_CREATE_COMPONENT(std::shared_ptr, serverConnectionHandler)([] { OATPP_COMPONENT(std::shared_ptr, router); // get Router component /* Create HttpProcessor::Components */ auto components = std::make_shared(router); /* Add content encoders */ auto encoders = std::make_shared(); encoders->add(std::make_shared()); encoders->add(std::make_shared()); /* Set content encoders */ components->contentEncodingProviders = encoders; /* return HttpConnectionHandler */ return std::make_shared(components); }()); ... ``` Now served content will be automatically compressed and streamed to the client if the client sets `Accept-Encoding` header appropriately. ### Automatically Decompress Uploaded Content Configure `server::ConnectionHandler` in `AppComponent.hpp`. ```cpp #include "oatpp-zlib/EncoderProvider.hpp" #include "oatpp/web/protocol/http/incoming/SimpleBodyDecoder.hpp" ... OATPP_CREATE_COMPONENT(std::shared_ptr, serverConnectionHandler)([] { OATPP_COMPONENT(std::shared_ptr, router); // get Router component /* Create HttpProcessor::Components */ auto components = std::make_shared(router); /* Add content decoders */ auto decoders = std::make_shared(); decoders->add(std::make_shared()); decoders->add(std::make_shared()); /* Set Body Decoder */ components->bodyDecoder = std::make_shared(decoders); /* return HttpConnectionHandler */ return std::make_shared(components); }()); ... ``` Now uploaded content will be automatically decompressed if the client sets `Content-Encoding` header properly.