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

deps: replace gzip handler #11843

Merged
merged 2 commits into from
Jan 19, 2022
Merged

deps: replace gzip handler #11843

merged 2 commits into from
Jan 19, 2022

Commits on Jan 19, 2022

  1. deps: swap gzip handler for gorilla

    This has been pinned since the Go modules migration, because the
    nytimes gzip handler was modified in version v1.1.0 in a way that
    is no longer compatible.
    
    Pretty sure it is this commit: nytimes/gziphandler@c551b6c
    
    Instead use handler.CompressHandler from gorilla, which is a web toolkit we already
    make use of for other things.
    shoenig committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    d061e8e View commit details
    Browse the repository at this point in the history
  2. deps: adjust to gzip handler zero length response body

    After swapping gzip handler to use the gorilla library, we
    must account for a quirk in how zero/minimal length response
    bodies are delivered.
    
    The previous gzip handler was configured to compress all responses
    regardless of size - even if the data was zero length or below the
    network MTU. This behavior changed in [v1.1.0](nytimes/gziphandler@c551b6c#diff-de723e6602cc2f16f7a9d85fd89d69954edc12a49134dab8901b10ee06d1879d)
    which is why we could not upgrade.
    
    The Nomad HTTP Client mutates the http.Response.Body object, making
    a strong assumption that if the Content-Encoding header is set to "gzip",
    the response will be readable via gzip decoder. This is no longer true
    for the nytimes gzip handler, and is also not true for the gorilla gzip
    handler.
    
    It seems in practice this only makes a difference on the /v1/operator/license
    endpoint which returns an empty response in OSS Nomad.
    
    The fix here is to simply not wrap the response body reader if we
    encounter an io.EOF while creating the gzip reader - indicating there
    is no data to decode.
    shoenig committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    e2ab168 View commit details
    Browse the repository at this point in the history