Commit a2ff4f23 authored by jan.koester's avatar jan.koester
Browse files

cache times for theme data

parent 2d0c3873
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -47,15 +47,17 @@

template<typename T>
void compress(const std::string in,std::string &out){
    size_t len=BrotliEncoderMaxCompressedSize(in.length());
    unsigned char *buf = new unsigned char[len];

    size_t len[2]={ BrotliEncoderMaxCompressedSize(in.length()),0};

    unsigned char *buf = new unsigned char[len[0]];

    BrotliEncoderCompress(BROTLI_DEFAULT_QUALITY,BROTLI_DEFAULT_WINDOW,BROTLI_MODE_TEXT,
                      in.length(),(const unsigned char*)in.c_str(),&len,buf);
                      in.length(),(const unsigned char*)in.c_str(),len,buf);

    out.resize(len);
    out.resize(len[1]);

    std::copy(buf,buf+len,std::inserter<std::string>(out,out.begin()));
    std::copy(buf,buf+len[1],std::inserter<std::string>(out,out.begin()));

    delete[] buf;
}
@@ -151,7 +153,8 @@ bool blogi::Template::Controller(netplus::con *curcon,libhttppp::HttpRequest *re
                    resp.setContentType("application/octet-stream");
                }

                if( curfile->Compressed.length() >0 && strstr(req->getData(req->getData("accept-encoding")),"br") ){
                if( curfile->Compressed.length() >0 && req->getData("accept-encoding")
                    && strstr(req->getData(req->getData("accept-encoding")),"br") ){
                    *resp.setData("content-encoding") << "br";
                    resp.send(curcon,curfile->Compressed.c_str(),curfile->Compressed.length());
                }else{