Fix bug with metrics/tracing middleware and HEAD responses#777
Merged
adam-fowler merged 1 commit intomainfrom Jan 30, 2026
Merged
Fix bug with metrics/tracing middleware and HEAD responses#777adam-fowler merged 1 commit intomainfrom
adam-fowler merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #777 +/- ##
==========================================
- Coverage 83.08% 83.05% -0.03%
==========================================
Files 124 124
Lines 6178 6180 +2
==========================================
Hits 5133 5133
- Misses 1045 1047 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
✅ Pull request no significant performance differences ✅ SummaryNew baseline 'pull_request' is WITHIN the 'main' baseline thresholds. Full Benchmark ComparisonComparing results between 'main' and 'pull_request'HummingbirdBenchmarksHTTP:Cookie:Decode metricsMalloc (total): results within specified thresholds, fold down for details.
HTTP:URI:Decode metricsMalloc (total): results within specified thresholds, fold down for details.
HTTP:URI:QueryParameters metricsMalloc (total): results within specified thresholds, fold down for details.
Router:Echo metricsMalloc (total): results within specified thresholds, fold down for details.
Router:GET metricsMalloc (total): results within specified thresholds, fold down for details.
Router:Middleware metricsMalloc (total): results within specified thresholds, fold down for details.
Router:PUT metricsMalloc (total): results within specified thresholds, fold down for details.
Router:Parameters metricsMalloc (total): results within specified thresholds, fold down for details.
RouterBuilder:Middleware metricsMalloc (total): results within specified thresholds, fold down for details.
TrieRouter:LongPaths metricsMalloc (total): results within specified thresholds, fold down for details.
TrieRouter:Parameters metricsMalloc (total): results within specified thresholds, fold down for details.
TrieRouter:Routing metricsMalloc (total): results within specified thresholds, fold down for details.
URLEncodedForm:Decode metricsMalloc (total): results within specified thresholds, fold down for details.
URLEncodedForm:Encode metricsMalloc (total): results within specified thresholds, fold down for details.
|
Joannis
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously when you set the body on a response if that body had a known length it would always fix the content-length header in a didSet call. The metrics and tracing middleware do this for every response so they can alter the response body writer to update timers and spans. This breaks responses from HEAD requests as the body is set on them and it resets the content-length.
This fix changes the didSet to a set and compares the old response body with the new one. If they have the same size then we don't update the content-length header.
This PR also fixes an issue where if you had a response with a content-length header and you later set the response body to be of an indeterminate length (perhaps you passed the response through a streaming compression middleware) it should clear the content-length header but it wasn't