Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip filter #914

Closed
wants to merge 14 commits into from
Closed

gzip filter #914

wants to merge 14 commits into from

Commits on Sep 3, 2023

  1. Libunit: added macros that enhance type safety.

    nxt_min()
    nxt_max()
        Return the minimum/maximum of two values.
    
    nxt_swap()
        Swap the values of two variables passed by their addresses.
    
    nxt_sizeof_array()
        Return the size (in bytes) of an array.
    
    nxt_nitems()
        Return the number of elements in an array.
    
    nxt_memberof()
        Expand to a member of a structure.  It uses a compound literal for
        the object.
    
    nxt_sizeof_incomplete()
        Calculate the size of an incomplete type, as if sizeof() could be
        applied to it.
    
    nxt_sizeof_fam0()
        Calculate the size of each element of a FAM of a structure.
    
    nxt_sizeof_fam()
        Calculate the size of a FAM of a structure.
    
    nxt_offsetof_fam()
        Calculate the offset of the nth element of the FAM from the start of
        the containing structure.
    
    nxt_sizeof_struct()
        Calculate the total size of a structure containing a FAM.  This
        value is the one that should be used for allocating the structure.
    
        Suggested-by: Andrew Clayton <[email protected]>
    
    nxt_is_near_end()
        Evaluate to true if the member is near the end of a structure.  This
        is only designed to be used with FAMs, to make sure that the FAM is
        near the end of the structure (a zero-length array near the end of
        the structure would still pass this test, but it's a reasonable
        assertion to do.
    
        Suggested-by: David Laight <[email protected]>
    
    nxt_is_zero_sizeof()
        Evaluate to true if the size of 'x' is 0.
    
    nxt_is_same_type()
        Evaluate to true if the both arguments are compatible types.
    
    nxt_is_same_typeof()
        Evaluate to true if the types of both arguments are compatible.
    
    nxt_is_array()
        Evaluate to true if the argument is an array.
    
    nxt_must_be()
        It's like static_assert(3), but implemented as an expression.  It's
        necessary for writing the must_be_array() macro.  It's always
        evaluates to (int) 0.
    
    nxt_must_be_array()
        Statically assert that the argument is an array.  It is an
        expression that always evaluates to (int) 0.
    
    nxt_must_be_zero_sizeof()
        Statically assert that the argument has a size of 0.
    
    nxt_must_be_near_end()
        Statically assert that a member of a structure is near the end of
        it.
    
        Suggested-by: David Laight <[email protected]>
    
    nxt_must_be_fam()
        Statically assert that the argument is a flexible array member
        (FAM).  It's an expression that always evaluates to (int) 0.
    
    Link: <https://gustedt.wordpress.com/2011/03/14/flexible-array-member/>
    Link: <https://lore.kernel.org/lkml/202308161913.91369D4A@keescook/T/>
    Link: <https://inbox.sourceware.org/gcc/[email protected]/T/>
    Link: <https://stackoverflow.com/a/57537491>
    Link: <shadow-maint/shadow#762>
    Cc: Andrew Clayton <[email protected]>
    Cc: Zhidao Hong <[email protected]>
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    de56ec6 View commit details
    Browse the repository at this point in the history
  2. HTTP: refactor: storing the body_handler as part of r.

    This will allow sending the header from a totally different point, since
    the data for the call is present in the request, which is available
    everywhere.
    
    It will also allow consulting in a filter if there is a body_handler
    installed.  The gzip filter will need this, as it should be a no-op if
    there is no body handler installed.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    ecc27ab View commit details
    Browse the repository at this point in the history
  3. HTTP: filter: supporting a list of filter_handlers

    Filter handlers are a new handler that takes place when a buffer is
    about to be sent.  It filters (modifies) the contents of the buffer
    in-place, so that the new contents will be sent.  Several filters can be
    applied in a loop.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    4977d28 View commit details
    Browse the repository at this point in the history
  4. HTTP: compress: added "compress" action.

    There are still no supported encodings.  This is just infrastructure for
    the next commits, which will add gzip compression.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    6e164a3 View commit details
    Browse the repository at this point in the history
  5. Auto: zlib: compiling with zlib.

    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    d3f4e09 View commit details
    Browse the repository at this point in the history

Commits on Sep 4, 2023

  1. HTTP: compress: added "encoding": "gzip".

    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    0080128 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7ecdc3d View commit details
    Browse the repository at this point in the history
  3. Auto: zlib: added --no-zlib.

    Related to:
    
        HTTP: compress: gzip
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    39db869 View commit details
    Browse the repository at this point in the history
  4. String: added strto[u]l(3) variants for nxt_str_t.

    They're really more inspired in the API of BSD's strto[iu](3), but use
    long just to keep it simple, instead of intmax_t, and since they wrap
    strtol(3), I called them like it.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    3dfab08 View commit details
    Browse the repository at this point in the history

Commits on Sep 5, 2023

  1. HTTP: compress: added configurable threshold for Content-Length.

    With this, short responses, that is, responses with a body of up to
    content_length_threshold bytes, won't be compressed.  The default value
    is 20, as in NGINX.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 5, 2023
    Configuration menu
    Copy the full SHA
    3348042 View commit details
    Browse the repository at this point in the history
  2. HTTP: compress: added "mime_types" rule.

    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 5, 2023
    Configuration menu
    Copy the full SHA
    77bda11 View commit details
    Browse the repository at this point in the history
  3. HTTP: compress: checking $header_accept_encoding.

    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 5, 2023
    Configuration menu
    Copy the full SHA
    861bc49 View commit details
    Browse the repository at this point in the history
  4. Libunit: added bit functions.

    These are based on C23's <stdbit.h>.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 5, 2023
    Configuration menu
    Copy the full SHA
    04e8bdf View commit details
    Browse the repository at this point in the history
  5. HTTP: compress: gzip: calculating wbits and memlevel dynamically.

    When the content length is small, optimize zlib for low memory usage.
    Conversely, when the content length is large, use a similar amount of
    memory within zlib, as it will improve compression, and won't hurt
    significantly.
    
    Signed-off-by: Alejandro Colomar <[email protected]>
    alejandro-colomar committed Sep 5, 2023
    Configuration menu
    Copy the full SHA
    993533a View commit details
    Browse the repository at this point in the history