serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evgeny Kotkov <evgeny.kot...@visualsvn.com>
Subject [PATCH] Support Brotli (RFC 7932) decompression
Date Tue, 07 Mar 2017 11:30:11 GMT
Hi,

This patch adds support for decompressing Brotli (RFC 7932) data and
allows decoding "Content-Encoding: br" responses with Serf.  Brotli is
a new compression format that is supported by browsers (Mozilla Firefox
since 44.0, Google Chrome since 50.0) and major web servers.

The patch introduces an optional dependency on the Brotli library from
https://github.com/google/brotli and a new bucket that allows decoding
Brotli data.  The new bucket features zero-copy processing, which is only
possible with the new API from the upcoming 1.0.x series of the library.

A quick way to try it is:

    svn co https://github.com/google/brotli.git/trunk brotli
    cd brotli
    ./configure-cmake --prefix=/home/me/brotli-install
    make install
    cd ../serf
    scons BROTLI=/home/me/brotli-install check

  (Similar on Windows, but requires plain 'cmake' calls to build Brotli.)


Log message:
[[[
Add support for decompressing Brotli (RFC 7932) data and allow decoding
"Content-Encoding: br" responses.

The patch introduces an optional dependency on the Brotli library from
https://github.com/google/brotli and a new bucket that allows decoding
Brotli data.  The new bucket features zero-copy processing, which is only
possible with the new API from the upcoming 1.0.x series of the library.

* serf_bucket_types.h
  (serf_bucket_is_brotli_supported,
   serf_bucket_brotli_decompress_create): Declare new functions.
  (SERF_BUCKET_IS_BROTLI_DECOMPRESS,
   serf_bucket_brotli_decompress_create): Declare new bucket type.

* buckets/brotli_buckets.c:
  New file containing the implementation of the new bucket.  Brotli is
  an optional dependency, so provide function stubs if it is not supported
  and indicate that in serf_bucket_is_brotli_supported().

* buckets/response_buckets.c
  (run_machine): Decode "Content-Encoding: br" if Brotli is supported.

* test/serf_bwtp.c
  (setup_request, setup_channel): Indicate Brotli support in "Accept-Encoding".

* test/serf_get.c
  (setup_request): Indicate Brotli support in "Accept-Encoding".

* test/serf_spider.c
  (setup_request): Indicate Brotli support in "Accept-Encoding".

* test/test_buckets.c
  (test_brotli_decompress_bucket_basic,
   test_brotli_decompress_bucket_truncated_input,
   test_brotli_decompress_bucket_read_bytewise,
   test_brotli_decompress_bucket_chunked_input,
   test_brotli_decompress_bucket_chunked_input2,
   test_brotli_decompress_bucket_garbage_at_end,
   test_brotli_decompress_response_body): New tests.
  (test_buckets): Run new tests if Serf is built with Brotli support.

* SConstruct: Pick up location of the Brotli library from the new
  BROTLI variable.  In case it's set, ensure that we are building
  with an appropriate version of the library and define SERF_HAVE_BROTLI.

Patch by: Evgeny Kotkov <evgeny.kotkov{_AT_}visualsvn.com>
]]]


Regards,
Evgeny Kotkov

Mime
View raw message