Skip to content

WireHttp::send() may fail if data is not reset before another request. #2131

@kixe

Description

@kixe

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");

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions