3 Commits
v4.2 ... v4.2.2

Author SHA1 Message Date
a76526a5b6 DEFAULT_CONNECTION_TIMEOUT default value increased to 120 2017-02-17 11:20:09 +01:00
baf32c1350 Curl is now returning response body even on error
It is better to switch off CURLOPT_FAILONERROR and check response status manually by HTTP response code
2017-02-17 11:07:26 +01:00
5c0bf914e3 Unused SoapClientNativeDataTransferObject removed 2017-02-17 03:36:16 +01:00
4 changed files with 12 additions and 38 deletions

View File

@ -62,7 +62,7 @@ class Curl
curl_setopt_array($curlSession, [ curl_setopt_array($curlSession, [
CURLOPT_ENCODING => '', CURLOPT_ENCODING => '',
CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FAILONERROR => true, CURLOPT_FAILONERROR => false,
CURLOPT_RETURNTRANSFER => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HEADER => true, CURLOPT_HEADER => true,
@ -147,6 +147,8 @@ class Curl
$headerSize = curl_getinfo($curlSession, CURLINFO_HEADER_SIZE); $headerSize = curl_getinfo($curlSession, CURLINFO_HEADER_SIZE);
$httpResponseCode = curl_getinfo($curlSession, CURLINFO_HTTP_CODE); $httpResponseCode = curl_getinfo($curlSession, CURLINFO_HTTP_CODE);
$httpResponseContentType = curl_getinfo($curlSession, CURLINFO_CONTENT_TYPE);; $httpResponseContentType = curl_getinfo($curlSession, CURLINFO_CONTENT_TYPE);;
$responseBody = substr($executeSoapCallResponse, $headerSize);
$responseHeaders = substr($executeSoapCallResponse, 0, $headerSize);
preg_match('/HTTP\/(1\.[0-1]+) ([0-9]{3}) (.*)/', $executeSoapCallResponse, $httpResponseMessages); preg_match('/HTTP\/(1\.[0-1]+) ([0-9]{3}) (.*)/', $executeSoapCallResponse, $httpResponseMessages);
$httpResponseMessage = trim(array_pop($httpResponseMessages)); $httpResponseMessage = trim(array_pop($httpResponseMessages));
$curlErrorMessage = sprintf( $curlErrorMessage = sprintf(
@ -156,7 +158,7 @@ class Curl
$location $location
); );
if ($executeSoapCallResponse === false) { if (!is_integer($httpResponseCode) || $httpResponseCode >= 400) {
return new CurlResponse( return new CurlResponse(
$httpRequestHeadersAsString, $httpRequestHeadersAsString,
@ -164,6 +166,8 @@ class Curl
$httpResponseMessage, $httpResponseMessage,
$httpResponseContentType, $httpResponseContentType,
self::CURL_FAILED, self::CURL_FAILED,
$responseHeaders,
$responseBody,
$curlErrorMessage $curlErrorMessage
); );
} }
@ -174,9 +178,8 @@ class Curl
$httpResponseMessage, $httpResponseMessage,
$httpResponseContentType, $httpResponseContentType,
self::CURL_SUCCESS, self::CURL_SUCCESS,
null, $responseHeaders,
substr($executeSoapCallResponse, 0, $headerSize), $responseBody
substr($executeSoapCallResponse, $headerSize)
); );
} }

View File

@ -13,7 +13,7 @@ use Exception;
class CurlOptionsBuilder class CurlOptionsBuilder
{ {
const DEFAULT_MAX_REDIRECTS = 10; const DEFAULT_MAX_REDIRECTS = 10;
const DEFAULT_CONNECTION_TIMEOUT = 10; const DEFAULT_CONNECTION_TIMEOUT = 120;
public static function buildDefault() public static function buildDefault()
{ {

View File

@ -19,9 +19,9 @@ class CurlResponse
$httpResponseStatusMessage, $httpResponseStatusMessage,
$httpResponseContentType, $httpResponseContentType,
$curlStatus, $curlStatus,
$curlErrorMessage = null, $responseHeader,
$responseHeader = null, $responseBody,
$responseBody = null $curlErrorMessage = null
) { ) {
$this->httpRequestHeaders = $httpRequestHeaders; $this->httpRequestHeaders = $httpRequestHeaders;
$this->httpResponseStatusCode = $httpResponseStatusCode; $this->httpResponseStatusCode = $httpResponseStatusCode;
@ -78,21 +78,11 @@ class CurlResponse
return $this->curlErrorMessage; return $this->curlErrorMessage;
} }
public function hasResponseHeader()
{
return $this->responseHeader !== null;
}
public function getResponseHeader() public function getResponseHeader()
{ {
return $this->responseHeader; return $this->responseHeader;
} }
public function hasResponseBody()
{
return $this->responseBody !== null;
}
public function getResponseBody() public function getResponseBody()
{ {
return $this->responseBody; return $this->responseBody;

View File

@ -1,19 +0,0 @@
<?php
namespace BeSimple\SoapClient;
class SoapClientNativeDataTransferObject
{
public $request;
public $location;
public $action;
public $version;
public function __construct($request, $location, $action, $version)
{
$this->request = $request;
$this->location = $location;
$this->action = $action;
$this->version = $version;
}
}