Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 3341894

Browse files
committed
allow to send not only get requests
1 parent a39a48e commit 3341894

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ZendDiagnostics/Check/GuzzleHttpService.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
class GuzzleHttpService extends AbstractCheck
1414
{
1515
protected $url;
16+
protected $method;
17+
protected $body;
1618
protected $headers;
1719
protected $statusCode;
1820
protected $content;
@@ -25,14 +27,18 @@ class GuzzleHttpService extends AbstractCheck
2527
* @param int $statusCode The response status code to check
2628
* @param null $content The response content to check
2729
* @param ClientInterface $guzzle Instance of guzzle to use
30+
* @param string $method The method of the request
31+
* @param mixed $body The body of the request (used for POST, PUT and DELETE requests)
2832
*/
29-
public function __construct($url, array $headers = array(), array $options = array(), $statusCode = 200, $content = null, ClientInterface $guzzle = null)
33+
public function __construct($url, array $headers = array(), array $options = array(), $statusCode = 200, $content = null, ClientInterface $guzzle = null, $method = 'GET', $body = null)
3034
{
3135
$this->url = $url;
3236
$this->headers = $headers;
3337
$this->options = $options;
3438
$this->statusCode = $statusCode;
3539
$this->content = $content;
40+
$this->method = $method;
41+
$this->body = $body;
3642

3743
if (!$guzzle) {
3844
$guzzle = new Client();
@@ -46,7 +52,7 @@ public function __construct($url, array $headers = array(), array $options = arr
4652
*/
4753
public function check()
4854
{
49-
$response = $this->guzzle->get($this->url, $this->headers, $this->options)->send();
55+
$response = $this->guzzle->createRequest($this->method, $this->url, $this->headers, $this->body, $this->options)->send();
5056

5157
if ($this->statusCode !== $statusCode = $response->getStatusCode()) {
5258
return new Failure("Status code {$this->statusCode} does not match {$statusCode} in response from {$this->url}");

0 commit comments

Comments
 (0)