virthttp  0.0
libvirt http interface
Enumerations | Functions | Variables
compression.hpp File Reference
#include <charconv>
#include <cstring>
#include <string>
#include <boost/beast.hpp>
#include <ctre.hpp>
#include <flatmap.hpp>
#include "libdeflate.hpp"

Go to the source code of this file.

Enumerations

enum  Algs { Algs::deflate, Algs::gzip, Algs::identity }
 

Functions

template<class Allocator >
bool handle_compression (const boost::beast::http::basic_fields< Allocator > &in_head, boost::beast::http::basic_fields< Allocator > &out_head, std::string &body)
 

Variables

static constexpr ctll::fixed_string weigthed_encodings_pattern = R"(([a-z]+|\*)(?:;q=([0-1].?(?:[\d]+)?)?)?(?:,\s*)?)"
 

Enumeration Type Documentation

enum Algs
strong

Available compression algorithms

Enumerator
deflate 
gzip 
identity 

Function Documentation

template<class Allocator >
bool handle_compression ( const boost::beast::http::basic_fields< Allocator > &  in_head,
boost::beast::http::basic_fields< Allocator > &  out_head,
std::string &  body 
)

Perform the appropriate compression on the response body

Template Parameters
Allocator(deduced)
Parameters
[in]in_headrequest header fields
[in]out_headresponse header fields
[in,out]bodyresponse body
Returns
true on success, false on failure

TODO check if the content-type looks like it could be compressed TODO check if the body is large enough to have any advantage compressing it

Variable Documentation

constexpr ctll::fixed_string weigthed_encodings_pattern = R"(([a-z]+|\*)(?:;q=([0-1].?(?:[\d]+)?)?)?(?:,\s*)?)"
static

Regex pattern for parsing boost::beast::http::field::accept_encoding's value