Skip to content

promhttp: Ignore informational response status codes when handling response #1773

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VirrageS
Copy link

Closes #1772

@VirrageS VirrageS changed the title promhttp: Ignore informational header when handling status code promhttp: Ignore informational response status codes when handling response Mar 12, 2025
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Any chances for a small unit test to ensure this works correctly long term? 🤗

Otherwise LGTM!

if !r.wroteHeader {
// Ignore informational response status codes.
// Based on https://github.com/golang/go/blob/go1.24.1/src/net/http/server.go#L1216
if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like:

Suggested change
if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols {
if code / 100 == 1 && code != http.StatusSwitchingProtocols {

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.

responseWriterDelegator incorrectly handles 100 Continue response
2 participants