Commit Graph

9 Commits

Author SHA1 Message Date
Moses Narrow 70037cf71f net/http: fix nil didTimeout deref when a client dial fails
Client.do calls didTimeout() on the error path (line 461), and the contract is
that send() returns a non-nil didTimeout whenever err != nil. TinyGo dropped
setRequestCancel but left the roundTrip error path returning the nil named
return value, so any http.Client{Timeout: ...} request whose dial failed (e.g.
connection refused) panicked with a nil func-value dereference instead of
returning the error. Return alwaysFalse on those error paths, matching the
other error returns in send().

Verified: http.Client{Timeout}.Get to a refused port now returns
"connection refused" instead of panicking.
2026-08-28 09:38:19 +02:00
Moses Narrow 902c8d1203 net/http: add ErrUseLastResponse, Client.CloseIdleConnections, Transport.Proxy and ProxyURL (#70)
* http: add ErrUseLastResponse and Client.CloseIdleConnections

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.
2026-08-27 09:08:14 +02:00
deadprogram 35e809e0e5 Upgrade net package from Go 1.21.4 to Go 1.26.2
Backport upstream Go standard library changes to TinyGo's net package.

Unmodified files (18) replaced directly from Go 1.26.2 source.
Modified files (22) merged via 3-way diff, preserving all TinyGo
netdev adaptations, TINYGO markers, and embedded-device constraints.

Notable upstream changes included:
- net/http: cookie handling improvements, fs enhancements,
  reverse proxy updates, chunked encoding fixes
- net/http: ServeMux routing and pattern matching updates
- net: IP parsing and MAC address handling improvements
- Various doc link syntax modernization (e.g. [Dial], [Buffers])

TinyGo-only files (netdev.go, tlssock.go) unchanged.
All TINYGO comment markers preserved.
2026-04-13 22:55:27 +01:00
Char bb43b40f19 http: add CheckRedirect field to Client for compatibility with oauth2
This change introduces a CheckRedirect field to the http.Client struct in TinyGo, 
mirroring the behavior of Go's standard library http.Client.

The purpose of this addition is to resolve build errors in projects that rely 
on packages (such as golang.org/x/oauth2) expecting the Client to have a 
CheckRedirect field. The field provides no functional change within TinyGo’s 
HTTP client at this time — it is only included for API compatibility and 
compilation success. There is no effect on runtime behavior unless explicitly 
used by downstream code.
2025-09-18 01:04:30 -04:00
Rajat Jindal 001ceab784 add bare minimum DefaultTransport (#32)
* add bare minimum DefaultTransport

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>

* use transport if explicitly configured by client

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>

---------

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
2024-07-09 13:26:29 -07:00
deadprogram 5fb7acc7b0 http: add Client RoundTripper/Transport
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-12-08 00:26:31 +01:00
Scott Feldman 7c11b88ce6 update with changes from go1.20.5 to go1.21.4 2023-11-24 18:26:04 +01:00
Scott Feldman c3616d9365 update 'net' package from 1.19.3 to 1.20.5 2023-07-07 20:00:29 +02:00
Scott Feldman 693edae782 Add network device driver model, netdev
This PR adds a network device driver model called netdev. There will be a companion PR for TinyGo drivers to update the netdev drivers and network examples. This PR covers the core "net" package.

An RFC for the work is here: #tinygo-org/drivers#487. Some things have changed from the RFC, but nothing major.

The "net" package is a partial port of Go's "net" package, version 1.19.3. The src/net/README file has details on what is modified from Go's "net" package.

Most "net" features are working as they would in normal Go. TCP/UDP/TLS protocol support is there. As well as HTTP client and server support. Standard Go network packages such as golang.org/x/net/websockets and Paho MQTT client work as-is. Other packages are likely to work as-is.

Testing results are here (https://docs.google.com/spreadsheets/d/e/2PACX-1vT0cCjBvwXf9HJf6aJV2Sw198F2ief02gmbMV0sQocKT4y4RpfKv3dh6Jyew8lQW64FouZ8GwA2yjxI/pubhtml?gid=1013173032&single=true).
2023-07-07 20:00:29 +02:00