Skip to content

Commit

Permalink
Allow the body of the request to be supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Ball committed Mar 29, 2017
1 parent d88e10e commit 6be476f
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,61 +34,65 @@ public function get(string $uri, array $headers = []): Crawler
/**
* Visit the given URI with a POST request.
*
* @param string $uri
* @param array $parameters
* @param array $headers
* @param string $uri
* @param array $parameters
* @param array $headers
* @param null|string $body
* @return Crawler
*/
public function post(string $uri, array $parameters = [], array $headers = []): Crawler
public function post(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
{
$server = $this->transformHeadersToServerVars($headers);

return $this->makeRequest('POST', $uri, $parameters, $server);
return $this->makeRequest('POST', $uri, $parameters, $server, $body);
}

/**
* Visit the given URI with a PUT request.
*
* @param string $uri
* @param array $parameters
* @param array $headers
* @param string $uri
* @param array $parameters
* @param array $headers
* @param null|string $body
* @return Crawler
*/
public function put(string $uri, array $parameters = [], array $headers = []): Crawler
public function put(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
{
$server = $this->transformHeadersToServerVars($headers);

return $this->makeRequest('PUT', $uri, $parameters, $server);
return $this->makeRequest('PUT', $uri, $parameters, $server, $body);
}

/**
* Visit the given URI with a PATCH request.
*
* @param string $uri
* @param array $parameters
* @param array $headers
* @param string $uri
* @param array $parameters
* @param array $headers
* @param null|string $body
* @return Crawler
*/
public function patch(string $uri, array $parameters = [], array $headers = []): Crawler
public function patch(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
{
$server = $this->transformHeadersToServerVars($headers);

return $this->makeRequest('PATCH', $uri, $parameters, $server);
return $this->makeRequest('PATCH', $uri, $parameters, $server, $body);
}

/**
* Visit the given URI with a DELETE request.
*
* @param string $uri
* @param array $parameters
* @param array $headers
* @param string $uri
* @param array $parameters
* @param array $headers
* @param null|string $body
* @return Crawler
*/
public function delete(string $uri, array $parameters = [], array $headers = []): Crawler
public function delete(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
{
$server = $this->transformHeadersToServerVars($headers);

return $this->makeRequest('DELETE', $uri, $parameters, $server);
return $this->makeRequest('DELETE', $uri, $parameters, $server, $body);
}

protected function makeRequest(
Expand Down

0 comments on commit 6be476f

Please sign in to comment.