Note that there are some explanatory texts on larger screens.

plurals
  1. POcurl_exec function causes server to drop the connection
    text
    copied!<p>I am having a strange issue with the following function that I have written. Briefly, this function connects to a URL and fetches the output by using curl functions. However, when I execute this function, I get a "server unexpectedly dropped the connection" message:</p> <pre><code>/** * Connects to remote URL and posts parameters, returns the result * * @param string $URL * @param string $ArrayPostParameters * @param string $HTTPRequestType * @param string $HTTPAuth * @param string $HTTPAuthUsername * @param string $HTTPAuthPassword * @param string $ConnectTimeOutSeconds * @param string $ReturnHeaders * @return array * @author xxxxxxxxxx */ function DataPostToRemoteURL($URL, $ArrayPostParameters, $HTTPRequestType = 'POST', $HTTPAuth = false, $HTTPAuthUsername = '', $HTTPAuthPassword = '', $ConnectTimeOutSeconds = 1, $ReturnHeaders = false) { $PostParameters = implode('&amp;', $ArrayPostParameters); $CurlHandler = curl_init(); curl_setopt($CurlHandler, CURLOPT_URL, $URL); if ($HTTPRequestType == 'GET') { curl_setopt($CurlHandler, CURLOPT_HTTPGET, true); } elseif ($HTTPRequestType == 'PUT') { curl_setopt($CurlHandler, CURLOPT_PUT, true); } elseif ($HTTPRequestType == 'DELETE') { curl_setopt($CurlHandler, CURLOPT_CUSTOMREQUEST, 'DELETE'); } else { curl_setopt($CurlHandler, CURLOPT_POST, true); curl_setopt($CurlHandler, CURLOPT_POSTFIELDS, $PostParameters); } curl_setopt($CurlHandler, CURLOPT_RETURNTRANSFER, 1); curl_setopt($CurlHandler, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($CurlHandler, CURLOPT_FOLLOWLOCATION, 5); curl_setopt($CurlHandler, CURLOPT_CONNECTTIMEOUT, $ConnectTimeOutSeconds); curl_setopt($CurlHandler, CURLOPT_TIMEOUT, $ConnectTimeOutSeconds); curl_setopt($CurlHandler, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'); // The option doesn't work with safe mode or when open_basedir is set. if ((ini_get('safe_mode') != false) &amp;&amp; (ini_get('open_basedir') != false)) { curl_setopt($CurlHandler, CURLOPT_FOLLOWLOCATION, true); } if ($ReturnHeaders == true) { curl_setopt($CurlHandler, CURLOPT_HEADER, true); } else { curl_setopt($CurlHandler, CURLOPT_HEADER, false); } if ($HTTPAuth == true) { curl_setopt($CurlHandler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($CurlHandler, CURLOPT_USERPWD, $HTTPAuthUsername.':'.$HTTPAuthPassword); } $RemoteContent = curl_exec($CurlHandler); if (curl_error($CurlHandler) != '') { return array(false, curl_error($CurlHandler)); } curl_close($CurlHandler); return array(true, $RemoteContent); } </code></pre> <p>When I debugged the function, I noticed that curl_exec() function causes this issue. No curl_error message and no PHP error is generated.</p> <p>Do you have any idea about reason(s)? safe_mode is disabled in PHP.INI for your information.</p> <p>Thanks for your help in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload