Skip to content

Commit 6be476f

Browse files
author
Stephen Ball
committed
Allow the body of the request to be supplied
1 parent d88e10e commit 6be476f

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/Concerns/MakesHttpRequests.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,61 +34,65 @@ public function get(string $uri, array $headers = []): Crawler
3434
/**
3535
* Visit the given URI with a POST request.
3636
*
37-
* @param string $uri
38-
* @param array $parameters
39-
* @param array $headers
37+
* @param string $uri
38+
* @param array $parameters
39+
* @param array $headers
40+
* @param null|string $body
4041
* @return Crawler
4142
*/
42-
public function post(string $uri, array $parameters = [], array $headers = []): Crawler
43+
public function post(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
4344
{
4445
$server = $this->transformHeadersToServerVars($headers);
4546

46-
return $this->makeRequest('POST', $uri, $parameters, $server);
47+
return $this->makeRequest('POST', $uri, $parameters, $server, $body);
4748
}
4849

4950
/**
5051
* Visit the given URI with a PUT request.
5152
*
52-
* @param string $uri
53-
* @param array $parameters
54-
* @param array $headers
53+
* @param string $uri
54+
* @param array $parameters
55+
* @param array $headers
56+
* @param null|string $body
5557
* @return Crawler
5658
*/
57-
public function put(string $uri, array $parameters = [], array $headers = []): Crawler
59+
public function put(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
5860
{
5961
$server = $this->transformHeadersToServerVars($headers);
6062

61-
return $this->makeRequest('PUT', $uri, $parameters, $server);
63+
return $this->makeRequest('PUT', $uri, $parameters, $server, $body);
6264
}
6365

6466
/**
6567
* Visit the given URI with a PATCH request.
6668
*
67-
* @param string $uri
68-
* @param array $parameters
69-
* @param array $headers
69+
* @param string $uri
70+
* @param array $parameters
71+
* @param array $headers
72+
* @param null|string $body
7073
* @return Crawler
7174
*/
72-
public function patch(string $uri, array $parameters = [], array $headers = []): Crawler
75+
public function patch(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
7376
{
7477
$server = $this->transformHeadersToServerVars($headers);
7578

76-
return $this->makeRequest('PATCH', $uri, $parameters, $server);
79+
return $this->makeRequest('PATCH', $uri, $parameters, $server, $body);
7780
}
7881

7982
/**
8083
* Visit the given URI with a DELETE request.
8184
*
82-
* @param string $uri
83-
* @param array $parameters
84-
* @param array $headers
85+
* @param string $uri
86+
* @param array $parameters
87+
* @param array $headers
88+
* @param null|string $body
8589
* @return Crawler
8690
*/
87-
public function delete(string $uri, array $parameters = [], array $headers = []): Crawler
91+
public function delete(string $uri, array $parameters = [], array $headers = [], ?string $body = null): Crawler
8892
{
8993
$server = $this->transformHeadersToServerVars($headers);
9094

91-
return $this->makeRequest('DELETE', $uri, $parameters, $server);
95+
return $this->makeRequest('DELETE', $uri, $parameters, $server, $body);
9296
}
9397

9498
protected function makeRequest(

0 commit comments

Comments
 (0)