[feat]: add HTTP transport to golang SDK
Merged
SE
2d ago+1487+1487+0123456789012345678901234567890123456789-17-17-01234567890123456789
why
the protocol now lets the worker ask an SDK to make an HTTP request. the golang SDK needs an implementation that can receive that request, send it over HTTP, & return the response while the original Stagehand call is still waiting
this PR adds the python implementation of #3205 using Go's standard net/http package
what changed
- added a connection snapshot that preserves browser-factory precedence, regional endpoints, & API URL overrides.
- added an executor for Gateway, cache read, & cache write requests. it applies bb headers & returns the buffered HTTP response, including errors & redirects
- prevented automatic replay of these POST requests so the worker continues to own retry decisions.
- carried context cancellation & the remaining timeout through response body reads, & closed response bodies and idle connections during cleanup.
- added RPC registration & cancellation by request ID. cancellation notifications are handled directly, so a busy log callback cannot delay them
test plan
- shared fixtures & connection tests cover endpoint selection, header precedence, & independent connection snapshots.
- local HTTP tests cover gzip/text decoding, empty bodies, redirects, network failures, & cancellation or timeout while reading a response.
- transport tests verify a dropped connection does not replay a received POST & that response bodies are closed.
- RPC tests cover concurrent requests, matching IDs on separate connections, disconnects, disposal, & cancellation while log delivery is blocked; race checks exercise the lifecycle paths.
Summary by cubic
Adds HTTP transport to the Go SDK so the Browserbase worker can request HTTP calls while the original Stagehand call is still waiting, matching the Python SDK implementation.
New Features
- Snapshots connection settings, including worker-claimed API key precedence, regional endpoints, and API URL overrides.
- Handles Gateway responses plus cache get and set operations, returning buffered responses with headers, errors, and redirects preserved.
- Prevents automatic replay of POST requests so the worker keeps retry decisions.
- Propagates context cancellation and remaining timeouts through response body reads and closes bodies and idle connections on cleanup.
- Registers RPC handlers per request ID, applies cancellation notifications directly without waiting on busy log callbacks, and drops responses issued during or after disposal and disconnect.