You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "lacklacklack (via GitHub)" <gi...@apache.org> on 2026/09/22 14:50:37 UTC

[PR] Add server-side gzip response compression [couchdb]

lacklacklack opened a new pull request, #6122:
URL: https://github.com/apache/couchdb/pull/6122

   ## Overview
   
   This PR adds optional gzip compression support for HTTP responses in CouchDB. When enabled, CouchDB will compress one-shot (non-chunked) HTTP responses using gzip if the client indicates support via the `Accept-Encoding: gzip` request header.
   
   The feature is disabled by default and can be enabled via a new `response_compression` configuration option in the `[chttpd]` section. Chunked/streaming responses (e.g. `_changes`, streaming views) are intentionally not affected by this setting and are deferred to a follow-up PR.
   
   ## Testing recommendations
   
   The change includes a new eunit test module (`chttpd_response_compression_test`) that covers three scenarios:
   
   1. **Default behaviour**: Compression is off by default — responses should not be gzip-encoded even when the client sends `Accept-Encoding: gzip`.
   2. **Compression enabled and accepted**: When `response_compression = true` and the client sends `Accept-Encoding: gzip`, the response body should be gzip-encoded and the `Content-Encoding: gzip` header should be present. The test also verifies the body is valid gzip by decompressing it with `zlib:gunzip/1`.
   3. **Compression enabled but not accepted**: When `response_compression = true` but the client does not send `Accept-Encoding: gzip`, the response should remain uncompressed.
   
   To manually test:
   - Enable the option by setting `response_compression = true` in `[chttpd]`
   - Make a request with `Accept-Encoding: gzip` (e.g. `curl -H "Accept-Encoding: gzip" http://localhost:5984/ --compressed`) and verify the response is compressed
   - Make a request without that header and verify the response is not compressed
   - Verify chunked endpoints like `_changes` are unaffected
   
   ## Related Issues or Pull Requests
   
   
   
   ## Checklist
   
   - [x] This is my own work, I did not use AI, LLM's or similar technology
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests
   - [x] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [x] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected branches


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add server-side gzip response compression [couchdb]

Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on PR #6122:
URL: https://github.com/apache/couchdb/pull/6122#issuecomment-5918026480

   @lacklacklack did you run erlfmt make check locally? The CI failure is stuck on erlfmt formatting
   
   ```
   make erlfmt-check
   22s
   08:34:09  + make erlfmt-check
   08:34:13    > Checking formatting...
   08:34:13    > [warn] src/couch/src/couch_httpd.erl
   08:34:13    > [warn] Code style issues found in the above file(s). Forgot to run erlfmt?
   08:34:13    > 
   08:34:31  
   08:34:31   1 error for src/couch/src/*.erl
   08:34:31  make: *** [Makefile:195: erlfmt-check] Error 1
   script returned exit code 2
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add server-side gzip response compression [couchdb]

Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on PR #6122:
URL: https://github.com/apache/couchdb/pull/6122#issuecomment-6126442011

   @lacklacklack the next failure looks like
   
   ```
   [2026-10-12T13:42:17.794Z] module 'chttpd_response_compression_test'
   [2026-10-12T13:42:17.794Z]   chttpd response compression tests
   [2026-10-12T13:42:17.794Z]     chttpd_response_compression_test:47: -compression_test_/0-fun-4- (t_no_compression_by_default)...[0.001 s] ok
   [2026-10-12T13:42:17.794Z]     chttpd_response_compression_test:48: -compression_test_/0-fun-2- (t_gzip_when_enabled_and_accepted)...*failed*
   [2026-10-12T13:42:17.794Z] in function chttpd_response_compression_test:t_gzip_when_enabled_and_accepted/1 (test/eunit/chttpd_response_compression_test.erl, line 66)
   [2026-10-12T13:42:17.794Z] in call from eunit_test:run_testfun/1 (eunit_test.erl, line 72)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:run_test/1 (eunit_proc.erl, line 544)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 369)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 527)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 469)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 359)
   [2026-10-12T13:42:17.794Z] in call from eunit_proc:run_group/2 (eunit_proc.erl, line 583)
   [2026-10-12T13:42:17.794Z] **error:{assertEqual,[{module,chttpd_response_compression_test},
   [2026-10-12T13:42:17.794Z]               {line,66},
   [2026-10-12T13:42:17.794Z]               {expression,"ContentEncoding"},
   [2026-10-12T13:42:17.794Z]               {expected,"gzip"},
   [2026-10-12T13:42:17.794Z]               {value,"identity"}]}
   [2026-10-12T13:42:17.794Z]   output:<<"">>
   [2026-10-12T13:42:17.794Z] 
   ```
   
   Does this pass locally?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org