Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@icio
Copy link

@icio icio commented Oct 14, 2025

The idea with this change is to inject the Tracker into the Request context with http.Server.BaseContext so that it is accessible in the SetResponseWriteEnforcer callback. Close the injected Tracker in a defer at the first layer of handle.

This is only adding enforcement at the time of WriteHeader, which is often implicitly called during the first Write. But this enforcement wouldn't catch the following pattern:

w.WriteHeader(200)
tx := db.Tx(ctx)
defer tx.Rollback()
w.Write(blob)

Updates tailscale/corp#7821
Updates #55

@icio icio requested a review from bradfitz October 14, 2025 15:54
@@ -0,0 +1,100 @@
package http_test
Copy link
Member

Choose a reason for hiding this comment

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

nice

@bradfitz
Copy link
Member

oh, but put [tailscale] in your git title first

@icio icio changed the title net/http: add SetResponseWriteEnforcer [tailscale] net/http: add SetResponseWriteEnforcer Oct 14, 2025
@icio icio force-pushed the icio/httprwenf branch 2 times, most recently from 2907351 to fd907a2 Compare October 14, 2025 20:30
Copy link
Member

@bradfitz bradfitz left a comment

Choose a reason for hiding this comment

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

Ship it

To use with Trackers, inject the Tracker into the Request context with
http.Server.BaseContext so that it is accessible in the
SetResponseWriteEnforcer callback. Close the injected Tracker in a defer at the
first layer of handle.

Updates tailscale/corp#7821
Updates #55
@bradfitz bradfitz merged commit 02dc1d8 into tailscale.go1.25 Oct 17, 2025
4 checks passed
@bradfitz bradfitz deleted the icio/httprwenf branch October 17, 2025 14:58
bradfitz added a commit to tailscale/tailscale that referenced this pull request Oct 17, 2025
Updates tailscale/go#140
Updates tailscale/go#142
Updates tailscale/go#138

Change-Id: Id25b6fa4e31eee243fec17667f14cdc48243c59e
Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit to tailscale/tailscale that referenced this pull request Oct 17, 2025
Updates tailscale/go#140
Updates tailscale/go#142
Updates tailscale/go#138

Change-Id: Id25b6fa4e31eee243fec17667f14cdc48243c59e
Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit to tailscale/tailscale that referenced this pull request Oct 17, 2025
Updates tailscale/go#140
Updates tailscale/go#142
Updates tailscale/go#138

Change-Id: Id25b6fa4e31eee243fec17667f14cdc48243c59e
Signed-off-by: Brad Fitzpatrick <[email protected]>
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.

2 participants