[squid-users] gzip deflate

joe chip_pop at hotmail.com
Thu Mar 17 09:56:02 UTC 2016


Alex Rousskov wrote
> On 03/16/2016 02:21 AM, joe wrote:
>> You need to direct messages to the service(s) using adaptation_access
>> directives:
>> isn't faster if we use gzip library instead that will minimize the
>> redirect
>> ms..direct decompress
> 
> Virtually everything would be faster if done directly in Squid. The
> processing speed is not the primary acceptance criteria, or we would
> never have ICAP, eCAP, URL rewriters, authentication helpers, SSL
> certificate validators, and other "helpers".
> 
> Compressing and uncompressing content on-the-fly is a lot more difficult
> than adding a couple of zlib function calls. It probably also requires
> several configuration/tuning options to accommodate various deployment
> environments. To make it worth implementing inside Squid, decompression
> has to be a very frequent feature request OR it has to be nearly
> impossible to do well outside of Squid (while still being reasonably
> popular). AFAICT, neither is true but please submit a more detailed
> proposal if I am wrong.
> 
> 
> Thank you,
> 
> Alex.
> 
> _______________________________________________
> squid-users mailing list

> squid-users at .squid-cache

> http://lists.squid-cache.org/listinfo/squid-users

it will be start for the future technologies  squid-gzip-deflate
Content-Encoding can be hook the code to decomp... insted of using ecap


yes there is a lot of work to have it fuly working but its start to the
develop....to continue working on it
there is lots a free snipe code arount and not hard to use it it fit in
recent squid code

just a sample code to adapt can be start of the work
#include <string>
#include <sstream>
#include <stdexcept>
#include <string.h>
#include "zlib.h"

using std::string;
using std::stringstream;

// Found these here
http://mail-archives.apache.org/mod_mbox/trafficserver-dev/201110.mbox/%3CCACJPjhYf=+br1W39vyazP=ix
//eQZ-4Gh9-U6TtiEdReG3S4ZZng at mail.gmail.com%3E
#define MOD_GZIP_ZLIB_WINDOWSIZE 15
/** Decompress an STL string using zlib and return the original data. */
std::string decompress_deflate(const std::string& str)
{
    z_stream zst;                        // z_stream is zlib's control
structure
    memset(&zst, 0, sizeof(zst));

    if (inflateInit(&zst) != Z_OK)
    debugs(98,1, "inflateInit failed while decompressing.");
    zst.next_in = (Bytef*)str.data();
    zst.avail_in = str.size();
    int ret;
    char outbuffer[32768];
    std::string outstring;

    // get the decompressed bytes blockwise using repeated calls to inflate
    do {
        zst.next_out = reinterpret_cast<Bytef*>(outbuffer);
        zst.avail_out = sizeof(outbuffer);
        ret = inflate(&zst, 0);
        if (outstring.size() < zst.total_out) {
            outstring.append(outbuffer,
                             zst.total_out - outstring.size());
        }

    } while (ret == Z_OK);

    inflateEnd(&zst);

    if (ret != Z_STREAM_END) {          // an error occurred that was not
EOF
        std::ostringstream oss;
		 debugs(98,2, oss << "Exception during deflate decompression: (" << ret <<
") " << zst.msg);
    }

    return outstring;
}

std::string decompress_gzip(const std::string& str)
{
    z_stream zst;                        // z_stream is zlib's control
structure
    memset(&zst, 0, sizeof(zst));
    if (inflateInit2(&zst, MOD_GZIP_ZLIB_WINDOWSIZE + 16) != Z_OK)
	    debugs(98,1, "error failed while decompressing.");
    zst.next_in = (Bytef*)str.data();
    zst.avail_in = str.size();
    int ret;
    char outbuffer[32768];
    std::string outstring;

    // get the decompressed bytes blockwise using repeated calls to inflate
    do {
        zst.next_out = reinterpret_cast<Bytef*>(outbuffer);
        zst.avail_out = sizeof(outbuffer);
        ret = inflate(&zst, 0);

        if (outstring.size() < zst.total_out) {
            outstring.append(outbuffer, zst.total_out - outstring.size());
        }

    } while (ret == Z_OK);

    inflateEnd(&zst);

    if (ret != Z_STREAM_END) {          // an error occurred that was not
EOF
        std::ostringstream oss;
		debugs(98,2, oss << "Exception during zlib decompression: (" << ret << ")
" << zst.msg);	
    }

    return outstring;
}

=========
 i know squid its hard coded to work with but its a start nothing essay but
it will be step to the future better then waiting for apps in the web to
become fully compressed and like the most preferred that then ecap  




--
View this message in context: http://squid-web-proxy-cache.1019090.n4.nabble.com/gzip-deflate-tp4676698p4676725.html
Sent from the Squid - Users mailing list archive at Nabble.com.


More information about the squid-users mailing list