nategood / httpful

A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.
MIT License
1.74k stars 299 forks source link

calling expectsJson() before body() of a post request breaks response parsing #299

Open lukemim opened 2 years ago

lukemim commented 2 years ago
$response = \Httpful\Request::post($url)
->expectsJson()
->body(['abc'=>123], \Httpful\Mime::FORM)
->send();

results in incorrect response body parsing, for example: Array (size=1) '{"exampleResponseFromServer":"data processed successfully"}' => string '' (length=0) (the entire raw response body is put in an array key and the array value is empty string)

When ->expectsJson() is called after ->body() the response JSON is parsed correctly.