Description
I am using a session to send multiple sequential requests. Some are GET, some are POST.
On a GET that is sent after a POST, I see that the content_ of the first request being used as custom method, see example below.
[03/Feb/2025 22:33:14] code 501, message Unsupported method ('{"thisIsMyJsonBody": "OfThePreviousPostRequest"}GET')
I'd expect the session to either internally reset content_(maybe in makeRequest?), or if not possible, I'd expect there to be the possibility of resetting content_ explicitly.
Since content_'s default is std::monostate, I'd like to introduce a reset function, setting std::monostate.
Interestingly enough, there already is a function hasBodyOrPayload which generates a custom GET request and a comment stating GET with body is illegal. But no setter/reset for content_.
Example/How to Reproduce
- Create a
cpr::Session
- Send POST
- Send GET (without changing content_ via its various setters)
- Perform the request
- Observe method shown in server which contains the body of the POST request.
Possible Fix
See above, I'd like to introduce a reset function for content_.
Where did you get it from?
conan
Additional Context/Your Environment
- OS: Linux
- Version: custom on kernel 5.15