From: Roland Häder Date: Thu, 29 Oct 2009 18:32:41 +0000 (+0000) Subject: sendGetRequest() now accepts a second optional parameter, so you can easily replace... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6f1b6e1a3f791d21d1b6465db310d21fe35804c8;p=mailer.git sendGetRequest() now accepts a second optional parameter, so you can easily replace sendPostRequest() with sendGetRequest() for testing purposes --- diff --git a/inc/functions.php b/inc/functions.php index e50b598ef3..7b074a4a55 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1742,10 +1742,25 @@ function extractHostnameFromUrl (&$script) { } // Send a GET request -function sendGetRequest ($script) { +function sendGetRequest ($script, $data = array()) { // Extract host name from script $host = extractHostnameFromUrl($script); + // Add data + $scriptData = http_build_query($data, '', '&'); + + // Do we have a question-mark in the script? + if (strpos($script, '?') === false) { + // No, so first char must be question mark + $scriptData = '?' . $scriptData; + } else { + // Ok, add & + $scriptData = '&' . $scriptData; + } + + // Add script data + $script .= $scriptData; + // Generate GET request header $request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL'); $request .= 'Host: ' . $host . getConfig('HTTP_EOL'); @@ -1782,7 +1797,7 @@ function sendPostRequest ($script, $postData) { $host = extractHostnameFromUrl($script); // Construct request - $data = http_build_query($postData, '','&'); + $data = http_build_query($postData, '', '&'); // Generate POST request header $request = 'POST /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL');