1313class 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