/** * @param $request RequestInterface The request to process. * @return Response * @throws \Exception */ public function call(RequestInterface $request) { $curl = $this->curl; $headers = [sprintf('Host: %s:%d', $this->host, $this->port), sprintf('Content-Length: %d', $request->length()), 'Expect: 100-continue']; // Set our headers. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); // Set the request information. curl_setopt($curl, CURLOPT_POSTFIELDS, $request->asString()); $str = curl_exec($curl); $rc = $request->getResponseClass(); if (!empty($str) && !empty($rc) && class_exists($rc)) { return new $rc($str); } else { throw new \Exception('cURL Error: ' . curl_error($curl)); } }