Showing with 35 additions and 131 deletions.
  1. +1 −126 README.md
  2. +33 −4 config
  3. +1 −1 deps/brotli
127 changes: 1 addition & 126 deletions README.md
@@ -1,128 +1,3 @@
# ngx_brotli

Brotli is a generic-purpose lossless compression algorithm that compresses data
using a combination of a modern variant of the LZ77 algorithm, Huffman coding
and 2nd order context modeling, with a compression ratio comparable to the best
currently available general-purpose compression methods. It is similar in speed
with deflate but offers more dense compression.

ngx_brotli is a set of two nginx modules:

- ngx_brotli filter module - used to compress responses on-the-fly,
- ngx_brotli static module - used to serve pre-compressed files.

[![TravisCI Build Status](https://travis-ci.org/eustas/ngx_brotli.svg?branch=master)](https://travis-ci.org/eustas/ngx_brotli)

## Status

Both Brotli library and nginx module are under active development.

## Installation

$ cd nginx-1.x.x
$ ./configure --add-module=/path/to/ngx_brotli
$ make && make install

## Configuration directives

### `brotli_static`

- **syntax**: `brotli_static on|off|always`
- **default**: `off`
- **context**: `http`, `server`, `location`

Enables or disables checking of the existence of pre-compressed files with`.br`
extension. With the `always` value, pre-compressed file is used in all cases,
without checking if the client supports it.

### `brotli`

- **syntax**: `brotli on|off`
- **default**: `off`
- **context**: `http`, `server`, `location`, `if`

Enables or disables on-the-fly compression of responses.

### `brotli_types`

- **syntax**: `brotli_types <mime_type> [..]`
- **default**: `text/html`
- **context**: `http`, `server`, `location`

Enables on-the-fly compression of responses for the specified MIME types
in addition to `text/html`. The special value `*` matches any MIME type.
Responses with the `text/html` MIME type are always compressed.

### `brotli_buffers`

- **syntax**: `brotli_buffers <number> <size>`
- **default**: `32 4k|16 8k`
- **context**: `http`, `server`, `location`

**Deprecated**, ignored.

### `brotli_comp_level`

- **syntax**: `brotli_comp_level <level>`
- **default**: `6`
- **context**: `http`, `server`, `location`

Sets Brotli quality (compression) `level`.
Acceptable values are in the range from `0` to `11`.

### `brotli_window`

- **syntax**: `brotli_window <size>`
- **default**: `512k`
- **context**: `http`, `server`, `location`

Sets Brotli window `size`. Acceptable values are `1k`, `2k`, `4k`, `8k`, `16k`,
`32k`, `64k`, `128k`, `256k`, `512k`, `1m`, `2m`, `4m`, `8m` and `16m`.

### `brotli_min_length`

- **syntax**: `brotli_min_length <length>`
- **default**: `20`
- **context**: `http`, `server`, `location`

Sets the minimum `length` of a response that will be compressed.
The length is determined only from the `Content-Length` response header field.

## Variables

### `$brotli_ratio`

Achieved compression ratio, computed as the ratio between the original
and compressed response sizes.

## Contributing

See [Contributing](CONTRIBUTING.md).

## License

Copyright (C) 2002-2015 Igor Sysoev
Copyright (C) 2011-2015 Nginx, Inc.
Copyright (C) 2015 Google Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Merged back to [google/ngx_brotli](https://github.com/eustas/ngx_brotli).
37 changes: 33 additions & 4 deletions config
Expand Up @@ -55,7 +55,21 @@ have=NGX_HTTP_BROTLI_STATIC_MODULE . auto/have # deprecated
# HTTP filter module with Brotli library
#

brotli="$ngx_addon_dir/deps/brotli"

ngx_module_type=HTTP_FILTER
ngx_module_name=ngx_http_brotli_filter_module

brotli="/usr/local"

if [ -f "/usr/include/brotli/encode.h" ]; then

brotli="/usr"

fi

if [ ! -f "$brotli/include/brotli/encode.h" ]; then

brotli="$ngx_addon_dir/deps/brotli/c"

if [ ! -f "$brotli/include/brotli/encode.h" ]; then
cat << END
Expand All @@ -71,8 +85,6 @@ END
exit 1
fi

ngx_module_type=HTTP_FILTER
ngx_module_name=ngx_http_brotli_filter_module
ngx_module_incs="$brotli/include"
ngx_module_deps="$brotli/common/constants.h \
$brotli/common/context.h \
Expand All @@ -81,6 +93,7 @@ ngx_module_deps="$brotli/common/constants.h \
$brotli/common/transform.h \
$brotli/common/version.h \
$brotli/enc/backward_references.h \
$brotli/enc/backward_references_hq.h \
$brotli/enc/backward_references_inc.h \
$brotli/enc/bit_cost.h \
$brotli/enc/bit_cost_inc.h \
Expand All @@ -99,10 +112,12 @@ ngx_module_deps="$brotli/common/constants.h \
$brotli/enc/entropy_encode_static.h \
$brotli/enc/fast_log.h \
$brotli/enc/find_match_length.h \
$brotli/enc/hash_forgetful_chain_inc.h \
$brotli/enc/hash.h \
$brotli/enc/hash_forgetful_chain_inc.h \
$brotli/enc/hash_longest_match64_inc.h \
$brotli/enc/hash_longest_match_inc.h \
$brotli/enc/hash_longest_match_quickly_inc.h \
$brotli/enc/hash_to_binary_tree_inc.h \
$brotli/enc/histogram.h \
$brotli/enc/histogram_inc.h \
$brotli/enc/literal_cost.h \
Expand All @@ -120,12 +135,14 @@ ngx_module_deps="$brotli/common/constants.h \
ngx_module_srcs="$brotli/common/dictionary.c \
$brotli/common/transform.c \
$brotli/enc/backward_references.c \
$brotli/enc/backward_references_hq.c \
$brotli/enc/bit_cost.c \
$brotli/enc/block_splitter.c \
$brotli/enc/brotli_bit_stream.c \
$brotli/enc/cluster.c \
$brotli/enc/compress_fragment.c \
$brotli/enc/compress_fragment_two_pass.c \
$brotli/enc/dictionary_hash.c \
$brotli/enc/encode.c \
$brotli/enc/encoder_dict.c \
$brotli/enc/entropy_encode.c \
Expand All @@ -137,6 +154,18 @@ ngx_module_srcs="$brotli/common/dictionary.c \
$brotli/enc/utf8_util.c \
$ngx_addon_dir/src/ngx_http_brotli_filter_module.c"
ngx_module_libs="-lm"

else # encode.h in /usr/local

ngx_module_incs="$brotli/include"
ngx_module_deps="$brotli/include/brotli/encode.h \
$brotli/include/brotli/port.h \
$brotli/include/brotli/types.h"
ngx_module_srcs="$ngx_addon_dir/src/ngx_http_brotli_filter_module.c"
ngx_module_libs="-lbrotlienc -lm"

fi # encode.h in /usr/local

ngx_module_order="$ngx_module_name \
ngx_pagespeed \
ngx_http_postpone_filter_module \
Expand Down
2 changes: 1 addition & 1 deletion deps/brotli
Submodule brotli updated 82 files
+1 −0 .gitignore
+22 −4 .travis.yml
+0 −87 BUILD
+31 −7 CMakeLists.txt
+14 −2 Makefile
+12 −87 WORKSPACE
+1 −1 c/common/dictionary.c
+236 −115 c/common/platform.h
+4 −5 c/common/transform.c
+2 −2 c/common/version.h
+1 −1 c/dec/bit_reader.h
+54 −44 c/dec/decode.c
+32 −49 c/dec/huffman.c
+55 −0 c/dec/huffman.h
+15 −0 c/enc/backward_references.c
+50 −55 c/enc/backward_references_hq.c
+6 −7 c/enc/backward_references_hq.h
+9 −9 c/enc/backward_references_inc.h
+3 −2 c/enc/brotli_bit_stream.h
+6 −6 c/enc/command.h
+5 −5 c/enc/compress_fragment.c
+90 −56 c/enc/compress_fragment_two_pass.c
+18 −22 c/enc/encode.c
+0 −1 c/enc/encoder_dict.h
+3 −1 c/enc/fast_log.h
+60 −11 c/enc/hash.h
+136 −0 c/enc/hash_composite_inc.h
+3 −2 c/enc/hash_longest_match64_inc.h
+3 −2 c/enc/hash_longest_match_inc.h
+216 −0 c/enc/hash_rolling_inc.h
+3 −2 c/enc/hash_to_binary_tree_inc.h
+2 −1 c/enc/metablock.c
+18 −0 c/enc/quality.h
+4 −6 c/enc/static_dict.c
+1 −1 c/enc/write_bits.h
+8 −3 c/fuzz/decode_fuzzer.c
+1 −1 c/fuzz/run_decode_fuzzer.c
+3 −4 c/fuzz/test_fuzzer.sh
+228 −32 c/include/brotli/port.h
+0 −7 c/include/brotli/types.h
+3 −4 c/tools/brotli.c
+2 −0 go/BUILD
+16 −0 go/WORKSPACE
+7 −7 go/cbrotli/BUILD
+86 −0 java/BUILD
+41 −0 java/WORKSPACE
+2 −9 java/org/brotli/dec/DictionaryData.java
+0 −1 java/org/brotli/dec/State.java
+17 −0 java/org/brotli/dec/Utils.java
+10 −10 java/org/brotli/integration/BUILD
+17 −21 java/org/brotli/wrapper/common/BUILD
+7 −30 java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
+19 −22 java/org/brotli/wrapper/dec/BUILD
+10 −1 java/org/brotli/wrapper/dec/BrotliInputStream.java
+10 −3 java/org/brotli/wrapper/dec/Decoder.java
+20 −25 java/org/brotli/wrapper/enc/BUILD
+3 −2 java/org/brotli/wrapper/enc/BrotliEncoderChannel.java
+3 −2 java/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java
+29 −0 java/org/brotli/wrapper/enc/EmptyInputTest.java
+10 −3 java/org/brotli/wrapper/enc/Encoder.java
+2 −0 js/BUILD
+14 −0 js/WORKSPACE
+81 −63 js/decode.js
+1 −1 js/decode.min.js
+1 −1 research/BUILD
+12 −0 research/WORKSPACE
+1 −1 research/draw_diff.cc
+1 −1 research/read_dist.h
+9 −5 scripts/.travis.sh
+31 −10 scripts/appveyor.yml
+3 −0 scripts/dictionary/README.md
+16 −0 scripts/dictionary/step-01-download-rfc.py
+34 −0 scripts/dictionary/step-02-rfc-to-bin.py
+38 −0 scripts/dictionary/step-03-validate-bin.py
+79 −0 scripts/dictionary/step-04-generate-java-literals.py
+8 −3 scripts/fix-win-bazel-build.py
+2 −0 scripts/sources.lst
+2 −0 setup.py
+4 −1 tests/compatibility_test.sh
+4 −1 tests/roundtrip_test.sh
+2 −0 tests/run-compatibility-test.cmake
+2 −0 tests/run-roundtrip-test.cmake