summaryrefslogtreecommitdiffstats
path: root/src/PurpleCode/PCurl/PCurl.php
diff options
context:
space:
mode:
authorMateusz Jaworski <niespammnie@gmail.com>2014-07-15 09:51:56 +0200
committerMateusz Jaworski <niespammnie@gmail.com>2014-07-15 09:51:56 +0200
commit2ebe98e90e172b2c824f4263b9367346392227c5 (patch)
treeb9a284b086b69e057386e11333d7ff15a130834d /src/PurpleCode/PCurl/PCurl.php
parent0e0aa739ec43eb6146bd483b0edd12b5928d93ee (diff)
parent090e64bd20a40ed55c79025e611ba2c6a45c80df (diff)
downloadphp.curl-2ebe98e90e172b2c824f4263b9367346392227c5.zip
php.curl-2ebe98e90e172b2c824f4263b9367346392227c5.tar.gz
php.curl-2ebe98e90e172b2c824f4263b9367346392227c5.tar.bz2
Merge pull request #1 from theres/master
PCurlResponse with body & headers
Diffstat (limited to 'src/PurpleCode/PCurl/PCurl.php')
-rw-r--r--src/PurpleCode/PCurl/PCurl.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/PurpleCode/PCurl/PCurl.php b/src/PurpleCode/PCurl/PCurl.php
index 4c2a428..4e9d4b6 100644
--- a/src/PurpleCode/PCurl/PCurl.php
+++ b/src/PurpleCode/PCurl/PCurl.php
@@ -12,8 +12,10 @@
namespace PurpleCode\PCurl;
require_once 'PCurlException.php';
+require_once 'PCurlResponse.php';
use PurpleCode\PCurl\PCurlException;
+use PurpleCode\PCurl\PCurlResponse;
class PCurl {
@@ -38,8 +40,8 @@ class PCurl {
$this->setOption(CURLOPT_SSL_VERIFYPEER, true);
// should curl_exec return response, not print it on stdout
$this->setOption(CURLOPT_RETURNTRANSFER, true);
- // should not include headers in response
- $this->setOption(CURLOPT_HEADER, 0);
+ // should include headers in response
+ $this->setOption(CURLOPT_HEADER, 1);
}
/**
@@ -103,8 +105,14 @@ class PCurl {
curl_close($curl);
throw new PCurlException($error);
}
+
+ $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
curl_close($curl);
- return $response;
+
+ $header = substr($response, 0, $header_size);
+ $body = substr($response, $header_size);
+
+ return new PCurlResponse($header, $body);
}
/**