@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function init($destination,$httpStatus) |
| 16 | 16 | { |
| 17 | 17 | $this->destination = $destination; |
| 18 | - $this->httpStatus = $httpStatus; |
|
| 18 | + $this->httpStatus = $httpStatus; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -25,39 +25,39 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function run() |
| 27 | 27 | { |
| 28 | - $ch = curl_init(); |
|
| 28 | + $ch = curl_init(); |
|
| 29 | 29 | |
| 30 | - curl_setopt( $ch, CURLOPT_URL, $this->destination ); |
|
| 30 | + curl_setopt( $ch, CURLOPT_URL, $this->destination ); |
|
| 31 | 31 | |
| 32 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 33 | - curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
| 34 | - curl_setopt( $ch, CURLOPT_HEADER, true ); |
|
| 35 | - curl_setopt( $ch, CURLOPT_NOBODY, true ); |
|
| 32 | + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 33 | + curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
| 34 | + curl_setopt( $ch, CURLOPT_HEADER, true ); |
|
| 35 | + curl_setopt( $ch, CURLOPT_NOBODY, true ); |
|
| 36 | 36 | |
| 37 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 ); // connect timeout |
|
| 38 | - curl_setopt( $ch, CURLOPT_TIMEOUT, 10 ); // curl timeout |
|
| 37 | + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 ); // connect timeout |
|
| 38 | + curl_setopt( $ch, CURLOPT_TIMEOUT, 10 ); // curl timeout |
|
| 39 | 39 | |
| 40 | - // @todo configurable timeouts (do not put hundreds of parameters to the init method) |
|
| 41 | - // @todo Handle SSL support on self-signed cert errors |
|
| 42 | - // @todo Optional setup outgoing proxy host and port configuration |
|
| 40 | + // @todo configurable timeouts (do not put hundreds of parameters to the init method) |
|
| 41 | + // @todo Handle SSL support on self-signed cert errors |
|
| 42 | + // @todo Optional setup outgoing proxy host and port configuration |
|
| 43 | 43 | |
| 44 | - $httpError = null; |
|
| 45 | - $httpStatus = null; |
|
| 46 | - if ( curl_exec( $ch ) === false ) { |
|
| 47 | - $httpError = curl_error( $ch ); |
|
| 48 | - } else { |
|
| 49 | - $httpStatus = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); |
|
| 50 | - } |
|
| 44 | + $httpError = null; |
|
| 45 | + $httpStatus = null; |
|
| 46 | + if ( curl_exec( $ch ) === false ) { |
|
| 47 | + $httpError = curl_error( $ch ); |
|
| 48 | + } else { |
|
| 49 | + $httpStatus = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - curl_close( $ch ); |
|
| 52 | + curl_close( $ch ); |
|
| 53 | 53 | |
| 54 | - if ( !is_null( $httpError ) ) { |
|
| 55 | - return new Result(Result::STATUS_FAIL, 'Http resource request ' . $this->destination . ' has an error ['.$httpError.']'); |
|
| 56 | - } elseif ( $httpStatus == $this->httpStatus ) { |
|
| 57 | - return new Result(Result::STATUS_PASS, 'Http resource status for ' . $this->destination . ' is ok ['.$httpStatus.']'); |
|
| 58 | - } else { |
|
| 59 | - return new Result(Result::STATUS_WARN, 'Http resource status for ' . $this->destination . ' is different ['.$this->httpStatus.' was expected but '.$httpStatus.' was delivered]' ); |
|
| 60 | - } |
|
| 54 | + if ( !is_null( $httpError ) ) { |
|
| 55 | + return new Result(Result::STATUS_FAIL, 'Http resource request ' . $this->destination . ' has an error ['.$httpError.']'); |
|
| 56 | + } elseif ( $httpStatus == $this->httpStatus ) { |
|
| 57 | + return new Result(Result::STATUS_PASS, 'Http resource status for ' . $this->destination . ' is ok ['.$httpStatus.']'); |
|
| 58 | + } else { |
|
| 59 | + return new Result(Result::STATUS_WARN, 'Http resource status for ' . $this->destination . ' is different ['.$this->httpStatus.' was expected but '.$httpStatus.' was delivered]' ); |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function getIdentifier() |