]> git.mxchange.org Git - mailer.git/blobdiff - inc/http-functions.php
Fix for wrong detection of broken HTTP server
[mailer.git] / inc / http-functions.php
index b0cbca319d79501193253058fab94b37f113ff3e..6289d6d2b81170fdbe89c71d5f5d8d9f7436956f 100644 (file)
@@ -267,7 +267,7 @@ function sendRawRequest ($host, $request) {
                // Check for broken HTTP implementations
                if (substr(strtolower($line), 0, 7) == 'server:') {
                        // Anomic (see http://anomic.de, http://yacy.net) is currently broken
-                       $GLOBALS['is_http_server_broken'] = in_array(trim(substr(strtolower($line), 7)), array('anomichttpd'));
+                       $GLOBALS['is_http_server_broken'] = (count(getArrayKeysFromSubStrArray(strtolower($line), array('anomichttpd'))) > 0);
                } // END - if
 
                // Add it to response
@@ -467,7 +467,7 @@ if (!function_exists('http_build_query')) {
                        if (is_array($v) || is_object($v)) {
                                array_push($ret, http_build_query($v, '', $sep, $k));
                        } else {
-                               array_push($ret, $k.'='.urlencode($v));
+                               array_push($ret, $k . '=' . urlencode($v));
                        }
                } // END - foreach
 
@@ -543,8 +543,9 @@ offset[<em>'.__LINE__.'</em>]='.$offset.'<br />';
 
                        /*
                         * Hack for e.g. YaCy HTTPDaemon (Anomic Server), this HTTP server
-                        * is currently (revision 7567) broken and does not include the \r\n
-                        * characters when it does sent "chunked" messages.
+                        * is currently (revision 7567 and maybe earlier) broken and does
+                        * not include the \r\n characters when it sents a "chunked" HTTP
+                        * message.
                         */
                        $count = 0;
                        if (isBrokenHttpServerImplentation()) {
@@ -552,7 +553,11 @@ offset[<em>'.__LINE__.'</em>]='.$offset.'<br />';
                                $count = call_user_func_array($mbPrefix . 'substr_count', array($next, getConfig('HTTP_EOL')));
                        } // END - if
 
-                       // Correct it because we need to subtract occurrences of \r\n
+                       /*
+                        * Correct chunk length because some broken HTTP server
+                        * implementation subtract occurrences of \r\n in their chunk
+                        * lengths.
+                        */
                        $chunkLen = hexdec(rtrim($chunkLenHex, getConfig('HTTP_EOL'))) - ($count * strlen(getConfig('HTTP_EOL')));
 
                        // Add next chunk to $dechunk
@@ -575,7 +580,7 @@ chunk=<pre>'.replaceReturnNewLine(htmlentities($chunk)).'</pre>');
                                break;
                        } // END - if
 
-                       // Calculate next offset of chunk
+                       // Calculate offset of next chunk
                        $offset = call_user_func_array($mbPrefix . 'strpos', array($chunk, getConfig('HTTP_EOL'), $offset + $chunkLen)) + 2;
 
                        /* DEBUG: *