private function ServicesClientConnectionCurlRequest::getDefaultCurlOptions in Services Client 7
Same name and namespace in other branches
- 7.2 services_client_connection/plugins/ServicesClientConnectionCurlRequest.inc \ServicesClientConnectionCurlRequest::getDefaultCurlOptions()
Retrieve default CURL options required for every CURL request
Parameters
ServicesClientConnectionHttpRequest $request: Request data that should be processed
Return value
array cURL opts array
4 calls to ServicesClientConnectionCurlRequest::getDefaultCurlOptions()
- ServicesClientConnectionCurlRequest::getCurlDeleteOptions in services_client_connection/
plugins/ ServicesClientConnectionCurlRequest.inc - Return the standard set of curl options for a DELETE
- ServicesClientConnectionCurlRequest::getCurlGetOptions in services_client_connection/
plugins/ ServicesClientConnectionCurlRequest.inc - Return the standard set of curl options for a GET
- ServicesClientConnectionCurlRequest::getCurlPostOptions in services_client_connection/
plugins/ ServicesClientConnectionCurlRequest.inc - Return the standard set of curl options for a POST
- ServicesClientConnectionCurlRequest::getCurlPutOptions in services_client_connection/
plugins/ ServicesClientConnectionCurlRequest.inc - Return the standard set of curl options for a PUT
File
- services_client_connection/
plugins/ ServicesClientConnectionCurlRequest.inc, line 47 - Make requests via cURL
Class
- ServicesClientConnectionCurlRequest
- @file Make requests via cURL
Code
private function getDefaultCurlOptions(&$request) {
// Add params to URL
if (!empty($request->query)) {
$request->url .= strpos($request->url, '?') === FALSE ? '?' : '&';
$request->url .= http_build_query($request->query, NULL, '&');
}
// Default options for every CURL request
$ret = array(
CURLOPT_URL => $request->url,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => isset($this->config['request_timeout']) ? $this->config['request_timeout'] : 5,
CURLOPT_HTTPHEADER => array(),
CURLOPT_HEADER => TRUE,
CURLINFO_HEADER_OUT => TRUE,
);
if ($request->data && empty($request->http_headers['Content-Length'])) {
$ret[CURLOPT_HTTPHEADER][] = 'Content-Length: ' . strlen($request->data);
}
foreach ($request->http_headers as $name => $value) {
if (is_string($name)) {
$ret[CURLOPT_HTTPHEADER][] = $name . ': ' . $value;
}
else {
$ret[CURLOPT_HTTPHEADER][] = $value;
}
}
// Optionally we can skip SSL verification
if (isset($this->config['ssl_verifypeer_skip']) && $this->config['ssl_verifypeer_skip']) {
$ret[CURLOPT_SSL_VERIFYPEER] = FALSE;
$ret[CURLOPT_SSL_VERIFYHOST] = FALSE;
}
return $ret;
}