Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Přidání možnosti modifikace Curl parametrů
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsedivy committed Feb 18, 2018
1 parent 8bd91b2 commit 1477e77
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private function initSoapClient()

if ($this->soapClient === null)
{
$this->soapClient = new SoapClient($this->service, $this->cert, $this->trace);
$this->soapClient = new SoapClient($this->service, $this->cert, $this->trace, $this->curlOptions);
}
}

Expand Down Expand Up @@ -433,5 +433,23 @@ public function getWarnings()
return $this->lastWarnings;
}

/**
* @param array|string $option
* @param null|string $value
*/
public function setCurlOption($option, $value = null)
{
if (is_array($option))
{
foreach ($option as $name => $value)
{
$this->setCurlOption($name, $value);
}
}
else
{
$this->curlOptions[$option] = $value;
}
}

}
10 changes: 9 additions & 1 deletion src/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ class SoapClient extends \SoapClient
/** @var int|null connection timeout in milliseconds */
private $connectTimeout = 2000;

/** @var array Curl options */
private $curlOptions = array();


/**
*
* @param string $service
* @param Certificate $cert
* @param bool $trace
* @param array $curlOptions
*/
public function __construct($service, Certificate $cert, $trace = false)
public function __construct($service, Certificate $cert, $trace = false, array $curlOptions = array())
{
$this->connectionStartTime = microtime(true);
parent::__construct($service, [
Expand All @@ -70,6 +74,7 @@ public function __construct($service, Certificate $cert, $trace = false)
]);
$this->cert = $cert;
$this->traceRequired = $trace;
$this->curlOptions = $curlOptions;
}


Expand Down Expand Up @@ -162,6 +167,9 @@ public function __doRequestByCurl($request, $location, $action, $version, $one_w
CURLOPT_HEADER => $headers,
CURLOPT_HTTPHEADER => array(sprintf('Content-Type: %s', $version == 2 ? 'application/soap+xml' : 'text/xml'), sprintf('SOAPAction: %s', $action)),
);

$options = $options + $this->curlOptions;

// Timeout in milliseconds
$options = $this->__curlSetTimeoutOption($options, $this->timeout, 'CURLOPT_TIMEOUT');
// ConnectTimeout in milliseconds
Expand Down

0 comments on commit 1477e77

Please sign in to comment.