40 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
41 curl_setopt($ch, CURLOPT_URL,
$message->getUrl());
42 if (!empty(
$message->requestHeaders)) {
43 curl_setopt($ch, CURLOPT_HTTPHEADER,
$message->requestHeaders);
45 curl_setopt($ch, CURLOPT_HEADER, 0);
47 if (
$message->getMethod() ===
'POST') {
48 curl_setopt($ch, CURLOPT_POST,
true);
49 curl_setopt($ch, CURLOPT_POSTFIELDS,
$message->request);
50 } elseif (
$message->getMethod() !==
'GET') {
51 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
$message->getMethod());
53 curl_setopt($ch, CURLOPT_POSTFIELDS,
$message->request);
56 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
57 curl_setopt($ch, CURLINFO_HEADER_OUT,
true);
58 curl_setopt($ch, CURLOPT_HEADER,
true);
59 $chResp = curl_exec($ch);
60 $message->requestHeaders = trim(str_replace(
"\r\n",
"\n", curl_getinfo($ch, CURLINFO_HEADER_OUT)));
61 $chResp = str_replace(
"\r\n",
"\n", $chResp);
62 $chRespSplit = explode(
"\n\n", $chResp, 2);
63 if ((count($chRespSplit) > 1) && (substr($chRespSplit[1], 0, 5) ===
'HTTP/')) {
64 $chRespSplit = explode(
"\n\n", $chRespSplit[1], 2);
66 $message->responseHeaders = trim($chRespSplit[0]);
67 if (count($chRespSplit) > 1) {
68 $message->response = $chRespSplit[1];
72 $message->status = curl_getinfo($ch, CURLINFO_HTTP_CODE);