Content-Length: 1 caused the slow response... :(
authorRoland Häder <roland@mxchange.org>
Thu, 26 Nov 2009 00:44:44 +0000 (00:44 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 26 Nov 2009 00:44:44 +0000 (00:44 +0000)
inc/functions.php

index aa691935e1f452796adb75cae04fdce88fbf1e81..a7cd723a8d52654eee61469a7306f962cc33a7cc 100644 (file)
@@ -1766,8 +1766,9 @@ function sendGetRequest ($script, $data = array()) {
        $request .= 'Accept-Charset: UTF-8,*' . getConfig('HTTP_EOL');
        $request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
        $request .= 'Content-Type: text/plain' . getConfig('HTTP_EOL');
-       $request .= 'Content-Length: '.strlen($body) . getConfig('HTTP_EOL');
-       $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+       $request .= 'Content-Length: 0' . getConfig('HTTP_EOL');
+       $request .= 'Connection: close' . getConfig('HTTP_EOL');
+       $request .= getConfig('HTTP_EOL');
 
        // Send the raw request
        $response = sendRawRequest($host, $request);
@@ -1798,7 +1799,10 @@ function sendPostRequest ($script, $postData) {
        $request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
        $request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
        $request .= 'Content-Type: application/x-www-form-urlencoded' . getConfig('HTTP_EOL');
-       $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+       $request .= 'Connection: close' . getConfig('HTTP_EOL');
+       $request .= getConfig('HTTP_EOL');
+
+       // Add body
        $request .= $body;
 
        // Send the raw request
@@ -1920,6 +1924,12 @@ function sendRawRequest ($host, $request) {
        // Close socket
        fclose($fp);
 
+       // Time request if debug-mode is enabled
+       if (isDebugModeEnabled()) {
+               // Add debug message...
+               logDebugMessage(__FUNCTION__, __LINE__, 'Request took ' . (microtime(true) - $start) . ' seconds.');
+       } // END - if
+
        // Skip first empty lines
        $resp = $response;
        foreach ($resp as $idx => $line) {