Skip to content

net/http: add ErrUseLastResponse, Client.CloseIdleConnections, Transport.Proxy and ProxyURL - #70

Merged
deadprogram merged 2 commits into
tinygo-org:mainfrom
0magnet:http-api-compat-fills
Aug 27, 2026
Merged

net/http: add ErrUseLastResponse, Client.CloseIdleConnections, Transport.Proxy and ProxyURL#70
deadprogram merged 2 commits into
tinygo-org:mainfrom
0magnet:http-api-compat-fills

Conversation

@0pcom

@0pcom 0pcom commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Four API-compatibility fills in net/http. Programs that reference any of them currently fail to compile against this package even when the feature is irrelevant to how they run.

  • ErrUseLastResponse — the sentinel a CheckRedirect func returns to stop following redirects. Nothing has to act on it beyond existing.
  • Client.CloseIdleConnections — delegates to the Transport when it has the method, which is what upstream net/http does.
  • ProxyURL — returns a proxy function that always yields the same URL.
  • Transport.Proxy — the field itself.

One caveat worth stating plainly: Transport.Proxy is accepted but not consulted. The netdev-backed transport dials directly. A caller that sets it gets a client that compiles and runs but ignores the proxy, which is a real footgun — I have commented it as such at the field. If you would rather not carry a field that silently does nothing, I am happy to drop Proxy/ProxyURL and keep only the first two, which have no such caveat.

Independent of #59 — this touches no netdev code and applies to main directly.

Found while building Skycoin's skywire against TinyGo, where each of these was a compile error before it was anything else.

Comment thread http/client.go Outdated
//
// To make a request with a specified context.Context, use [NewRequestWithContext]
// and Client.Do.
// CloseIdleConnections closes any connections on its Transport which were

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method is placed directly into the comments from the Get method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — it was sitting inside the Client.Get doc block, orphaning that comment. Moved to after Client.Head, which is where upstream Go has it. Code motion only.

0pcom added 2 commits August 25, 2026 13:30
Both are API-compatibility fills. ErrUseLastResponse is a sentinel a
CheckRedirect func returns to stop following redirects; nothing here has
to act on it beyond existing. CloseIdleConnections delegates to the
Transport when it has the method, which is what net/http does.

Programs that reference either currently fail to compile against this
package for want of a name, which is the whole cost.
Same as the TLSHandshakeTimeout one: what matters is that the field exists for
API compatibility, not which project happens to set it.
@0pcom
0pcom force-pushed the http-api-compat-fills branch from b6fd871 to 1e17dbc Compare August 25, 2026 18:31
@deadprogram

Copy link
Copy Markdown
Member

Now squash/merging. Thanks for the improvement @0pcom

@deadprogram
deadprogram merged commit 902c8d1 into tinygo-org:main Aug 27, 2026
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