diff --git a/src/Request.php b/src/Request.php index e4ae738..7b33149 100644 --- a/src/Request.php +++ b/src/Request.php @@ -131,13 +131,6 @@ public function getResponseCode():int { return (int)$this->curl->getInfo(CURLINFO_HTTP_CODE); } -public function getResponse() { - $response = new Response(); - -// until Response is developed, pass back the Curl object. - return $this->curl; -} - private function curlInit($options = []) { $defaultOptions = []; @@ -169,6 +162,7 @@ private function curlInit($options = []) { // The returntransfer option MUST be set, otherwise the promise resolution // callbacks will not be able to get the content of the HTTP requests. $options[CURLOPT_RETURNTRANSFER] = true; + $options[CURLOPT_HEADER] = true; $this->curl->setOptArray($options); } diff --git a/src/RequestResolver.php b/src/RequestResolver.php index 4194a1f..1cff3a3 100644 --- a/src/RequestResolver.php +++ b/src/RequestResolver.php @@ -48,8 +48,12 @@ public function tick() { $request = $this->matchRequest($info["handle"]); if($request->getResponseCode() === 200) { $requestIndex = array_search($request, $this->requestArray); + $curl = $request->getCurlHandle(); $this->deferredArray[$requestIndex]->resolve( - $request->getResponse() + new Response( + $this->curlMulti->getContent($curl), + $curl->getInfo() + ) ); } diff --git a/src/Response.php b/src/Response.php index d049a9b..b77b414 100644 --- a/src/Response.php +++ b/src/Response.php @@ -1,6 +1,73 @@ headers[trim($kvp[0])] = trim($kvp[1]); + } + + $this->body = substr($rawResponse, $headerSize); + $this->curlInfo = $curlInfo; +} + +// TODO: Move these functions to the `Body` trait. (Issue #8). + +public function arrayBuffer() { + +} + +public function blob() { + +} + +public function clone() { + +} + +public function error() { + +} + +public function formData() { + +} + +public function json() { + +} + +public function redirect() { + +} + +public function text() { + +} }# \ No newline at end of file