diff options
author | Arron Woods <aw@chartblocks.com> | 2015-02-11 11:24:38 +0000 |
---|---|---|
committer | Arron Woods <aw@chartblocks.com> | 2015-02-11 11:24:56 +0000 |
commit | aff709498462a699a2e93a0e7116f4321d777ade (patch) | |
tree | 9742d9bfba02c86cd9282aec849f5c4d5d6e8fe4 /library | |
parent | 95047c4a13003400734fcd40c887c16002737590 (diff) | |
download | php-ssrs-aff709498462a699a2e93a0e7116f4321d777ade.zip php-ssrs-aff709498462a699a2e93a0e7116f4321d777ade.tar.gz php-ssrs-aff709498462a699a2e93a0e7116f4321d777ade.tar.bz2 |
Unit test for NTLM headers
Diffstat (limited to 'library')
-rwxr-xr-x | library/SSRS/Soap/NTLM.php | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/library/SSRS/Soap/NTLM.php b/library/SSRS/Soap/NTLM.php index cc5b0fd..7f75db7 100755 --- a/library/SSRS/Soap/NTLM.php +++ b/library/SSRS/Soap/NTLM.php @@ -131,24 +131,13 @@ class NTLM extends \SoapClient { curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true); curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); - $headers = array( - 'Method: ' . (($data === null) ? 'GET' : 'POST'), - 'Connection: Keep-Alive', - 'User-Agent: PHP-SOAP-CURL', - ); + $headers = $this->generateHeaders($url, $data, $action); + curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); if ($data !== null) { - $headers[] = 'Content-Type: text/xml; charset=utf-8'; - $headers[] = 'Content-Length: ' . strlen($data); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); } - if ($action !== null) { - $headers[] = 'SOAPAction: "' . $action . '"'; - } - - curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); - $response = curl_exec($handle); if ($response === false) { throw new SSRS_Soap_Exception('CURL error: ' . curl_error($handle), curl_errno($handle)); @@ -174,4 +163,30 @@ class NTLM extends \SoapClient { return $this->_lastResponse; } + /** + * + * @param string $url + * @param mixed $data + * @param string $action + * @return array + */ + public function generateHeaders($url, $data = null, $action = null) { + $headers = array( + 'Method: ' . (($data === null) ? 'GET' : 'POST'), + 'Connection: Keep-Alive', + 'User-Agent: PHP-SOAP-CURL', + ); + + if ($data !== null) { + $headers[] = 'Content-Type: text/xml; charset=utf-8'; + $headers[] = 'Content-Length: ' . strlen($data); + } + + if ($action !== null) { + $headers[] = 'SOAPAction: "' . $action . '"'; + } + + return $headers; + } + } |