/** * Send a CURL request. * * @return Vinelab\Http\Response */ public function send() { $cURLOptions = array(CURLOPT_HTTP_VERSION => $this->getCurlHttpVersion(), CURLOPT_URL => $this->url, CURLOPT_CUSTOMREQUEST => $this->method, CURLOPT_RETURNTRANSFER => $this->returnTransfer, CURLOPT_HTTPHEADER => $this->headers, CURLOPT_HEADER => true, CURLINFO_HEADER_OUT => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 50); if ($this->method === static::method('POST') || $this->method === static::method('PUT') || $this->method === static::method('PATCH')) { if (count($this->params) > 0) { $cURLOptions[CURLOPT_POST] = count($this->params); $cURLOptions[CURLOPT_POSTFIELDS] = $this->json ? json_encode($this->params) : $this->params; } elseif (!is_null($this->content)) { $cURLOptions[CURLOPT_POST] = strlen($this->content); $cURLOptions[CURLOPT_POSTFIELDS] = $this->json ? json_encode($this->content) : $this->content; } } elseif (count($this->params) > 0) { $this->url = $this->url . '?' . http_build_query($this->params); $cURLOptions[CURLOPT_URL] = $this->url; } elseif (!is_null($this->content)) { $cURLOptions[CURLOPT_URL] = $this->url . '?' . $this->content; } // initialize cURL $cURL = curl_init(); curl_setopt_array($cURL, $cURLOptions); return Response::make($cURL); }
/** * Send a CURL request. * * @return Vinelab\Http\Response */ public function send() { $cURLOptions = array(CURLOPT_HTTP_VERSION => $this->getCurlHttpVersion(), CURLOPT_URL => $this->url, CURLOPT_CUSTOMREQUEST => $this->method, CURLOPT_HTTPHEADER => $this->headers, CURLOPT_HEADER => true, CURLINFO_HEADER_OUT => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => $this->maxRedirects, CURLOPT_TIMEOUT => $this->timeout); //digest auth support if (count($this->digestAuth) > 0) { $cURLOptions[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST; $cURLOptions[CURLOPT_USERPWD] = $this->digestAuth['username'] . ":" . $this->digestAuth['password']; } else { if (count($this->basicAuth) > 0) { $cURLOptions[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; $cURLOptions[CURLOPT_USERPWD] = $this->basicAuth['username'] . ":" . $this->basicAuth['password']; } } if ($this->method === static::method('POST') || $this->method === static::method('PUT') || $this->method === static::method('PATCH')) { if (count($this->params) > 0) { $cURLOptions[CURLOPT_POST] = count($this->params); $cURLOptions[CURLOPT_POSTFIELDS] = $this->json ? json_encode($this->params) : $this->params; } elseif (!is_null($this->content)) { $cURLOptions[CURLOPT_POST] = strlen($this->content); $cURLOptions[CURLOPT_POSTFIELDS] = $this->json ? json_encode($this->content) : $this->content; } } elseif (count($this->params) > 0) { $this->url = $this->url . '?' . http_build_query($this->params); $cURLOptions[CURLOPT_URL] = $this->url; } elseif (!is_null($this->content)) { $cURLOptions[CURLOPT_URL] = $this->url . '?' . $this->content; } // initialize cURL $cURL = curl_init(); curl_setopt_array($cURL, $cURLOptions); return Response::make($cURL); }