-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
HTTP GET request may fail if the data is not reset before another request. It should be reset by default. For each request type, there is a $data argument (an empty array by default) that should not be ignored even if it is empty.
$http = new WireHttp();
// do a post request
$data = ["foo" => "bar"];
$http->post("https://example.org/api/v1/endpoint1", $data);
// fails, because previously set data is sent
$http->get("https://example.org/api/v1/endpoint2");
// works
$http->setData([]); // unset data array
$http->get("https://example.org/api/v1/endpoint2");
// do another post request
$rawData = "{"foo":"bar"}";
$http->post("https://example.org/api/v1/endpoint3", $rawData);
// fails, because previously set rawData is sent
$http->get("https://example.org/api/v1/endpoint4");
// works
$http->setData(null); // unset rawData string
$http->get("https://example.org/api/v1/endpoint4");