oficina / meet Public

callscore: keep a replaced default transport rather than panic

38ad0b7's internal/callstest TestMain installs keymailtest's transport as
http.DefaultTransport; safeClient asserted *http.Transport and panicked,
so make native-browser died in TestNativeBrowserAppLink before running
anything. It clones the default only when it is an *http.Transport.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 81f2dcee4fbf227b6f15afa506c9d9a922998299 parent 092bff3
1 file changed, +11 −3
  • callscore/transport.go +11 −3

CI passed — run details

CI log
=== vet ===
go vet ./...
=== fmt ===
=== test ===
go test ./...
ok  	amadan.net/oficina/calls/callscore	7.289s
ok  	amadan.net/oficina/calls/cmd/calls	13.187s
ok  	amadan.net/oficina/calls/cmd/quality-summary	0.003s
ok  	amadan.net/oficina/calls/internal/calls	2.167s
ok  	amadan.net/oficina/calls/internal/calls/apns	0.007s
ok  	amadan.net/oficina/calls/internal/calls/hub	0.337s
?   	amadan.net/oficina/calls/internal/calls/icons	[no test files]
?   	amadan.net/oficina/calls/internal/calls/keymailtest	[no test files]
ok  	amadan.net/oficina/calls/internal/calls/relay	0.003s
ok  	amadan.net/oficina/calls/internal/calls/seal	0.002s
ok  	amadan.net/oficina/calls/internal/callstest	10.075s
?   	amadan.net/oficina/calls/protocol	[no test files]
?   	amadan.net/oficina/calls/scripts/writeestilo	[no test files]
=== migration-check ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo migration check
rastrillo migration check: models and migrations agree
=== race ===
CGO_ENABLED=1 go test -race ./internal/...
ok  	amadan.net/oficina/calls/internal/calls	12.850s
ok  	amadan.net/oficina/calls/internal/calls/apns	1.024s
ok  	amadan.net/oficina/calls/internal/calls/hub	2.899s
?   	amadan.net/oficina/calls/internal/calls/icons	[no test files]
?   	amadan.net/oficina/calls/internal/calls/keymailtest	[no test files]
ok  	amadan.net/oficina/calls/internal/calls/relay	1.019s
ok  	amadan.net/oficina/calls/internal/calls/seal	1.013s
ok  	amadan.net/oficina/calls/internal/callstest	30.776s
diff --git a/callscore/transport.go b/callscore/transport.go
index a953645..e64b3d7 100644
--- a/callscore/transport.go
+++ b/callscore/transport.go
@@ -74,9 +74,17 @@ func safeClient(client *http.Client) (*http.Client, error) {
}
safe := *client
if safe.Transport == nil {
- transport := http.DefaultTransport.(*http.Transport).Clone()
- transport.ResponseHeaderTimeout = 15 * time.Second
- safe.Transport = transport
+ // The default transport, with a deadline on the response's
+ // headers. A process that has replaced it (internal/callstest's
+ // TestMain installs keymailtest's, which answers DNS in-process)
+ // keeps its own: asserting *http.Transport panicked there.
+ if base, ok := http.DefaultTransport.(*http.Transport); ok {
+ transport := base.Clone()
+ transport.ResponseHeaderTimeout = 15 * time.Second
+ safe.Transport = transport
+ } else {
+ safe.Transport = http.DefaultTransport
+ }
}
safe.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }
safe.Timeout = 0 // streams live for five minutes; individual calls have deadlines