Commit d384f96
committed
fix: reset request body before x402 retry to prevent exhausted reader
X402Transport.RoundTrip clones the request twice (first attempt + retry)
but Clone() shares the body reader without calling GetBody(). After the
first attempt consumes the body, the retry gets an exhausted reader,
causing 'ReverseProxy does an invalid Read on closed Body'.
Add bodyResetTransport that calls GetBody() before each RoundTrip,
ensuring each attempt gets a fresh reader. Pairs with the existing
bodyBufferMiddleware which guarantees GetBody is always set.1 parent 4787287 commit d384f96
1 file changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
339 | 358 | | |
340 | 359 | | |
341 | 360 | | |
| |||
0 commit comments