Commit 97acb7bf authored by mikeytown2's avatar mikeytown2

Issue #1889006 by mikeytown2: Fix some of the readme examples.

parent 7f921776
...@@ -216,6 +216,8 @@ connections that couldn't be made will be dropped. ...@@ -216,6 +216,8 @@ connections that couldn't be made will be dropped.
$options = array( $options = array(
'method' => 'HEAD', 'method' => 'HEAD',
'blocking' => FALSE, 'blocking' => FALSE,
'domain_connections' => 1000,
'global_connections' => 1000,
); );
// Queue up the requests. // Queue up the requests.
$max = 1000; $max = 1000;
...@@ -235,9 +237,9 @@ connections that couldn't be made will be dropped. ...@@ -235,9 +237,9 @@ connections that couldn't be made will be dropped.
Request 1000 URLs in a non blocking manner with one httprl_request() call. These Request 1000 URLs in a non blocking manner with one httprl_request() call. These
URLs will all have the same options. This will saturate the server. All 1000 URLs will all have the same options. This will saturate the server. Usually all
requests will eventually hit the server due to it waiting for the connection to 1000 requests will eventually hit the server due to it waiting for the
be established; `async_connect` is FALSE. connection to be established; `async_connect` is FALSE.
<?php <?php
// Set the blocking mode. // Set the blocking mode.
...@@ -245,6 +247,10 @@ be established; `async_connect` is FALSE. ...@@ -245,6 +247,10 @@ be established; `async_connect` is FALSE.
'method' => 'HEAD', 'method' => 'HEAD',
'blocking' => FALSE, 'blocking' => FALSE,
'async_connect' => FALSE, 'async_connect' => FALSE,
// domain_connections must be smaller than the servers max number of
// clients.
'domain_connections' => 32,
'global_connections' => 1000,
); );
// Queue up the requests. // Queue up the requests.
$max = 1000; $max = 1000;
...@@ -360,7 +366,8 @@ instead of returning a value. ...@@ -360,7 +366,8 @@ instead of returning a value.
**More Advanced HTTP Operations** **More Advanced HTTP Operations**
Hit 4 different URLs, Using at least 2 that has a status code of 200 and Hit 4 different URLs, Using at least 2 that has a status code of 200 and
erroring out the others that didn't return fast. Data is truncated as well. erroring out the others that didn't return fast. Using the Range header so only
the first and last 128 bytes are returned.
<?php <?php
// Array of URLs to get. // Array of URLs to get.
...@@ -375,7 +382,7 @@ erroring out the others that didn't return fast. Data is truncated as well. ...@@ -375,7 +382,7 @@ erroring out the others that didn't return fast. Data is truncated as well.
// Process list of URLs. // Process list of URLs.
$options = array( $options = array(
'alter_all_streams_function' => 'need_two_good_results', 'alter_all_streams_function' => 'need_two_good_results',
'callback' => array(array('function' => 'limit_data_size')), 'headers' => array('Range' => 'bytes=0-127,-128'),
); );
// Queue up the requests. // Queue up the requests.
httprl_request($urls, $options); httprl_request($urls, $options);
...@@ -412,11 +419,6 @@ erroring out the others that didn't return fast. Data is truncated as well. ...@@ -412,11 +419,6 @@ erroring out the others that didn't return fast. Data is truncated as well.
} }
} }
} }
function limit_data_size(&$result) {
// Only use the first and last 256 characters in the data array.
$result->data = substr($result->data, 0, 256) . "\n\n ... \n\n" . substr($result->data, strlen($result->data)-256);
}
?> ?>
......
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