go-ethereum/p2p
Daniel Liu 58e9b8c8f6
node, rpc: improve HTTP write timeout handling #25457 (#982)
Here we add special handling for sending an error response when the write timeout of the
HTTP server is just about to expire. This is surprisingly difficult to get right, since is
must be ensured that all output is fully flushed in time, which needs support from
multiple levels of the RPC handler stack:

The timeout response can't use chunked transfer-encoding because there is no way to write
the final terminating chunk. net/http writes it when the topmost handler returns, but the
timeout will already be over by the time that happens. We decided to disable chunked
encoding by setting content-length explicitly.

Gzip compression must also be disabled for timeout responses because we don't know the
true content-length before compressing all output, i.e. compression would reintroduce
chunked transfer-encoding.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-04-25 08:01:44 +08:00
..
discover p2p, p2p/discover: add dial metrics (#27621) 2025-02-18 16:05:59 +08:00
discv5 all: use T.TempDir to create temporary test directories (#24633) 2025-01-24 16:54:08 +08:00
enr crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
nat all: replace strings.Replace with string.ReplaceAll (#24835) 2024-12-08 11:51:14 +08:00
netutil p2p/netutil: fix staticcheck warning SA1021: not use bytes.Equal to compare net.IPs 2024-11-01 11:35:42 +08:00
protocols all: refactor package node #21105 (#923) 2025-04-10 18:52:49 +08:00
simulations node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
dial.go p2p, p2p/discover: add dial metrics (#27621) 2025-02-18 16:05:59 +08:00
dial_test.go Revert EIP-2464 2024-08-24 02:31:27 +07:00
message.go p2p: measure subprotocol bandwidth usage (#20133) 2025-03-19 18:01:32 +08:00
message_test.go all: fix go vet warnings 2016-04-15 11:17:27 +02:00
metrics.go p2p: measure subprotocol bandwidth usage (#20133) 2025-03-19 18:01:32 +08:00
peer.go p2p: measure subprotocol bandwidth usage (#20133) 2025-03-19 18:01:32 +08:00
peer_error.go all: fix staticcheck warning ST1006: don't use generic name self 2024-10-25 21:30:54 +08:00
peer_test.go p2p: fix staticcheck warning SA4030: rand.Intn(1) always returns 0 2024-11-01 11:32:56 +08:00
protocol.go Revert EIP-2464 2024-08-24 02:31:27 +07:00
rlpx.go p2p: measure subprotocol bandwidth usage (#20133) 2025-03-19 18:01:32 +08:00
rlpx_test.go crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
server.go all: refactor package node #21105 (#923) 2025-04-10 18:52:49 +08:00
server_test.go all: fix warning of DeepEqual on error #23624 (#960) 2025-04-24 18:31:47 +08:00