Commit e9641ea1 authored by mikeytown2's avatar mikeytown2

Issue #1455528 by mikeytown2: Update documentation in code.

parent fdeb5fed
......@@ -399,11 +399,11 @@ function httprl_request($url, $options = array()) {
// Merge the default headers.
// Set user agent to drupal.
// Set connection to closed to prevent keep-alive from causing a timeout.
// Set referrer to current page.
$options['headers'] += array(
'User-Agent' => 'Drupal (+http://drupal.org/)',
'Connection' => 'close',
);
// Set referrer to current page.
if (!isset($options['headers']['Referer']) && !empty($options['referrer'])) {
$options['headers']['Referer'] = $base_root . request_uri();
}
......@@ -506,11 +506,11 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
$stream_select_timeout = 1;
while (!empty($streams)) {
// Check for timeouts.
// Get time.
$current_time = timer_read($timer_name) / 1000;
$global_time = $global_timeout - timer_read($timer_name) / 1000;
// Set connection limits.
// Initialize connection limits.
$this_run = array();
$global_connection_count = 0;
$domain_connection_count = array();
......@@ -578,6 +578,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
}
}
// Set the connection limits for this run.
// Get the host name.
$host = $responses[$id]->options['headers']['Host'];
// Count up the number of connections.
......@@ -602,7 +603,8 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
// Set the read and write vars to the streams var.
$read = $write = $this_run;
$except = array();
// Do some voodoo and open all streams at once. Wait 25ms for streams to respond.
// Do some voodoo and open all streams at once. Wait 25ms for streams to
// respond.
$n = stream_select($read, $write, $except, $stream_select_timeout, 25000);
$stream_select_timeout = 0;
......@@ -611,7 +613,8 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
if (!empty($n)) {
$empty_runs = 0;
// Readable sockets either have data for us, or are failed connection attempts.
// Readable sockets either have data for us, or are failed connection
// attempts.
foreach ($read as $r) {
$id = array_search($r, $streams);
// Make sure ID is in the streams.
......@@ -641,7 +644,8 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
// See if the headers are in the data stream.
httprl_parse_data($responses[$id]);
if (!empty($responses[$id]->headers)) {
// Stream was a redirect, close this connection; redirect is being followed.
// Stream was a redirect, close this connection; redirect is being
// followed.
if (!empty($responses[$id]->redirect_url)) {
$responses[$id]->status = 'Done.';
fclose($r);
......@@ -675,6 +679,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
if ($stream_write_count > 0) {
foreach ($write as $w) {
$id = array_search($w, $streams);
// Make sure ID is in the streams & staus is for writing.
if ($id === FALSE || empty($responses[$id]->status) || $responses[$id]->status != 'in progress') {
continue;
}
......@@ -1080,6 +1085,7 @@ function httprl_decode_data(&$result) {
* int - Content length.
*/
function httprl_background_processing($output, $wait = TRUE, $content_type = "text/html; charset=utf-8", $length = 0) {
// Can't do background processing if headers are already sent.
if (headers_sent()) {
return FALSE;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment