[go] net/http/httptrace: document Got1xxResponse compose behavior

3 views
Skip to first unread message

John S (Gerrit)

unread,
Feb 3, 2026, 9:24:59 AM (4 days ago) Feb 3
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

John S has uploaded the change for review

Commit message

net/http/httptrace: document Got1xxResponse compose behavior

Document that when Got1xxResponse hooks are composed via WithClientTrace,
both hooks are called but only the previously-registered hook's return
value is used. The new hook's return value is discarded.

This behavior comes from the generic compose function which calls both
hooks but only returns the old hook's result (trace.go lines 202-205).

Verified by testing: when two Got1xxResponse hooks are composed, both
are executed but only the old hook's error is returned.

Fixes #76669
Co-Authored-By: Claude Opus 4.5 <nor...@anthropic.com>
Change-Id: I726c998de6d3228faaf6123184200f87e3c2f38f

Change diff

diff --git a/src/net/http/httptrace/trace.go b/src/net/http/httptrace/trace.go
index cee13d2..65f74da 100644
--- a/src/net/http/httptrace/trace.go
+++ b/src/net/http/httptrace/trace.go
@@ -112,6 +112,10 @@
// returned before the final non-1xx response. Got1xxResponse is called
// for "100 Continue" responses, even if Got100Continue is also defined.
// If it returns an error, the client request is aborted with that error value.
+ //
+ // When Got1xxResponse hooks are composed via [WithClientTrace], both hooks
+ // are called but only the previously-registered hook's return value is used;
+ // the new hook's return value is discarded.
Got1xxResponse func(code int, header textproto.MIMEHeader) error

// DNSStart is called when a DNS lookup begins.

Change information

Files:
  • M src/net/http/httptrace/trace.go
Change size: XS
Delta: 1 file changed, 4 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I726c998de6d3228faaf6123184200f87e3c2f38f
Gerrit-Change-Number: 741500
Gerrit-PatchSet: 1
Gerrit-Owner: John S <xau...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
Feb 4, 2026, 6:09:14 PM (2 days ago) Feb 4
to John S, goph...@pubsubhelper.golang.org, Damien Neil, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Damien Neil and John S

Sean Liao added 1 comment

File src/net/http/httptrace/trace.go
Line 116, Patchset 1 (Latest): // When Got1xxResponse hooks are composed via [WithClientTrace], both hooks
Sean Liao . unresolved

the policy should be documented at the struct level, we shouldn't have to repeat the same docs if we add a new hook.

Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • John S
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I726c998de6d3228faaf6123184200f87e3c2f38f
    Gerrit-Change-Number: 741500
    Gerrit-PatchSet: 1
    Gerrit-Owner: John S <xau...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Sean Liao <se...@liao.dev>
    Gerrit-Attention: John S <xau...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Wed, 04 Feb 2026 23:09:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Damien Neil (Gerrit)

    unread,
    Feb 6, 2026, 6:31:36 PM (8 hours ago) Feb 6
    to John S, goph...@pubsubhelper.golang.org, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from John S and Sean Liao

    Damien Neil added 2 comments

    File src/net/http/httptrace/trace.go
    Line 116, Patchset 1 (Latest): // When Got1xxResponse hooks are composed via [WithClientTrace], both hooks
    Sean Liao . resolved

    the policy should be documented at the struct level, we shouldn't have to repeat the same docs if we add a new hook.

    Damien Neil

    I think we can cross that bridge if and when we add any other hooks which can modify the request process. (And I don't think we should add any such hooks; Got1xxResponse sits uncomfortably here because it's about modifying the request path rather than tracing it.)

    Line 118, Patchset 1 (Latest): // the new hook's return value is discarded.
    Damien Neil . unresolved

    I feel like this is documenting bad behavior, when we should fix it instead. I'd expect a request to be aborted if any Got1xxResponse hook returns an error.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • John S
    • Sean Liao
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I726c998de6d3228faaf6123184200f87e3c2f38f
    Gerrit-Change-Number: 741500
    Gerrit-PatchSet: 1
    Gerrit-Owner: John S <xau...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Sean Liao <se...@liao.dev>
    Gerrit-Attention: Sean Liao <se...@liao.dev>
    Gerrit-Attention: John S <xau...@gmail.com>
    Gerrit-Comment-Date: Fri, 06 Feb 2026 23:31:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Sean Liao <se...@liao.dev>
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages