8000
Skip to content

Fix compile of ngx_brotli for newer nginx version (with new MSVC) - #179

Open
sebres wants to merge 3 commits into
google:masterfrom
sebres:patch-1
Open

Fix compile of ngx_brotli for newer nginx version (with new MSVC)#179
sebres wants to merge 3 commits into
google:masterfrom
sebres:patch-1

Conversation

@sebres
@sebres sebres commented Jun 16, 2026
Copy link
Copy Markdown
Contributor

This PR fixes compilation of ngx_brotli for newer nginx version (with new MSVC):

  1. Adjust conditional check for MSVC version to new nginx version
    NGX_MSVC_VER was removed in nginx/nginx/commit/99312be10c0edd554a40df03591ed2d905f8bd10
  2. Update CFLAGS for MSVC configuration: force include ngx_config.h for precompiled header instead of -Y-:
    modern MSVC compilers (Visual Studio 2022 and newer) no longer recognize or support the legacy -Y- syntax
    (amend to eb2f8a0).
  3. Fix MSVC build without interim cmake to out-dir, when brotli sources directly compiled to ngx_brotli
    (amend to 63ca02a)

sebres and others added 3 commits June 16, 2026 17:30
NGX_MSVC_VER was removed in nginx/nginx/commit/99312be10c0edd554a40df03591ed2d905f8bd10
modern MSVC compilers (Visual Studio 2022 and newer) no longer recognize or support the legacy -Y- syntax
(amend to eb2f8a0)
mreiden added a commit to mreiden/ngx_brotli that referenced this pull request Aug 27, 2026
Port of the sibling nginx-zstd-module's google#179 to the brotli static module,
which carried the identical pattern: it allocated the body ngx_buf_t and
its ngx_file_t and filled every field before calling ngx_http_send_header()
and returning on req->header_only. For a HEAD there is no body, so those
two pool allocations and the field setup are pure waste.

Return right after send_header() when req->method == NGX_HTTP_HEAD, before
the allocations. Strict method equality, not req->header_only (which also
covers 304/204 — those keep the existing header_only return past the body
setup). Placed after Content-Encoding and the Vary line are set, so a HEAD
advertises exactly what its GET would.

Test: 00-brotli TEST 19 — a HEAD to a served .br sidecar carries the same
Content-Encoding, Vary: Accept-Encoding, and Accept-Ranges: bytes as the
GET, with no body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0