Commit bf1015f6 authored by Antonio.Suerte's avatar Antonio.Suerte

Callback Sender Update [Response Header]

parent 0d77e2c3
......@@ -39,6 +39,12 @@ class ConnectSite extends FrameworkTest {
*/
private $connectRequestMethod = NO_STRING;
/**
*
* @var boolean
*/
private $showResponseHeaders = false;
/**
*
* @var array
......@@ -128,16 +134,21 @@ class ConnectSite extends FrameworkTest {
if(is_array($this -> payload -> requestHeaders))
$this -> connectRequestHeader = $this -> payload -> requestHeaders;
}
if(isset($this -> payload -> responseHeaders)){
$this -> showResponseHeaders = $this -> payload -> responseHeaders;
}
}
private function processRequest(&$statusCode = NO_STRING){
$handle = curl_init($this -> connectURL);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $this -> requestMethod);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $this -> requestMethod);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handle, CURLOPT_ENCODING, "utf8");
curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($handle, CURLOPT_HEADER, $this -> showResponseHeaders);
if($this -> isLoopData($this -> connectRequestHeader)){
curl_setopt($handle, CURLOPT_HTTPHEADER, $this -> connectRequestHeader);
......@@ -147,7 +158,18 @@ class ConnectSite extends FrameworkTest {
curl_setopt($handle, CURLOPT_POSTFIELDS, $this -> connectRequestParams);
}
$output = curl_exec($handle);
if($this -> showResponseHeaders){
$output = curl_exec($handle);
$headerSize = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
$responseHeaders = substr($output, 0, $headerSize);
$responseBody = substr($output, $headerSize);
$output = "[Headers]\n\n{$responseHeaders}[Body]\n\n{$responseBody}";
}else
$output = curl_exec($handle);
$statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($err = curl_error($handle)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment