go-resty / resty

Simple HTTP and REST client library for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request body is written multiple times

patrikeh opened this issue · comments

In v2.10.0, I've observed an issue where the request body passed to .SetBody(...) is intermittently written multiple times under certain conditions.

From what I gather, it is somehow related to the retry mechanism, or at the very least I was only able to reproduce by triggering that.

In the repro here, I ping an httptest mock endpoint triggering the retry mechanism, and observe the JSON request body being written multiple consecutive times e.g.


{ <some-json> }{ <some-json> }

This issue does not occur in v2.9.1.

My projcet recurred this bug. Hope fix.
For more information, we tried all versions 2.8.0-2.10.0 and recurred in those versions.

@patrikeh thanks for throwing that test case together, really helped with tracking the issue down