Title: HEAD scrapes write a response body when gzip is negotiated · Issue #2665 · prometheus/client_java · GitHub
Open Graph Title: HEAD scrapes write a response body when gzip is negotiated · Issue #2665 · prometheus/client_java
X Title: HEAD scrapes write a response body when gzip is negotiated · Issue #2665 · prometheus/client_java
Description: What happened? A HEAD scrape with Accept-Encoding: gzip enters the compression path in PrometheusScrapeHandler and writes a gzip response body. The non-compressed path already suppresses HEAD bodies. Reproduced on main at 85d9fb0dca9f064...
Open Graph Description: What happened? A HEAD scrape with Accept-Encoding: gzip enters the compression path in PrometheusScrapeHandler and writes a gzip response body. The non-compressed path already suppresses HEAD bodie...
X Description: What happened? A HEAD scrape with Accept-Encoding: gzip enters the compression path in PrometheusScrapeHandler and writes a gzip response body. The non-compressed path already suppresses HEAD bodie...
Opengraph URL: https://github.com/prometheus/client_java/issues/2665
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"HEAD scrapes write a response body when gzip is negotiated","articleBody":"### What happened?\n\nA `HEAD` scrape with `Accept-Encoding: gzip` enters the compression path in `PrometheusScrapeHandler` and writes a gzip response body. The non-compressed path already suppresses HEAD bodies.\n\nReproduced on main at `85d9fb0dca9f064c746470e91b924d253abf8d30` using the existing `PrometheusScrapeHandlerTest` exchange: a HEAD request with gzip produces 69 bytes, where the body must be empty. It also calls `sendHeadersAndGetBody(200, 0)` instead of the no-body length `-1` used by the existing HEAD path.\n\n### Expected behavior\n\nHEAD should return the negotiated headers, including `Content-Type` and `Content-Encoding: gzip`, without constructing a gzip stream or writing response bytes. GET gzip behavior should be unchanged.\n\n### Reproduction\n\nIn the existing handler test fixture:\n\n```java\nTestHttpExchange exchange =\n new TestHttpExchange(\"HEAD\", null).withHeader(\"Accept-Encoding\", \"gzip\");\nhandler.handleRequest(exchange);\nassertThat(exchange.rawResponseBody.size()).isZero();\n```\n\nBefore the fix, the assertion fails with actual `69`. I have a small fix and regression coverage prepared; the 17 handler tests pass on Java 25 with default Error Prone/NullAway enabled.\n\nAI assistance was used for investigation and test preparation.","author":{"url":"https://github.com/yangjj-iso","@type":"Person","name":"yangjj-iso"},"datePublished":"2026-11-07T14:07:05Z","url":"https://github.com/prometheus/client_java/issues/2665"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a57ed116-859a-b4bf-c746-f5337d6ab0a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBEC:122F7E:1A4169:22ECD5:6AFBB2DB |
| html-safe-nonce | 10afafd9e3b9dcc51ccb54cce5bf6373512abd0dafb27d03b25bfa44cb8da1cf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkVDOjEyMkY3RToxQTQxNjk6MjJFQ0Q1OjZBRkJCMkRCIiwidmlzaXRvcl9pZCI6IjExODUxNDc4MzE0MzQ1ODg4OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f1972cad0af9afd8bfcbeec328306add40eeb34157858ef89612021a9c101541 |
| hovercard-subject-tag | issue:6259965929 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/2665/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f5057a5f706815e3b83962ebc09b37b76a9ea93a111e75d0a2094416fafba973/prometheus/client_java/issues/2665 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f5057a5f706815e3b83962ebc09b37b76a9ea93a111e75d0a2094416fafba973/prometheus/client_java/issues/2665 |
| og:image:alt | What happened? A HEAD scrape with Accept-Encoding: gzip enters the compression path in PrometheusScrapeHandler and writes a gzip response body. The non-compressed path already suppresses HEAD bodie... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yangjj-iso |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_java git https://github.com/prometheus/client_java.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 7997879 |
| octolytics-dimension-repository_nwo | prometheus/client_java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7997879 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width