Commit e13c3864 authored by mikeytown2's avatar mikeytown2

Issue #1837776 by mikeytown2: Update readme.txt so examples set the Host...

Issue #1837776 by mikeytown2: Update readme.txt so examples set the Host header when using httprl_build_url_self().
parent 42c0f7f0
...@@ -65,7 +65,8 @@ API OVERVIEW ...@@ -65,7 +65,8 @@ API OVERVIEW
Issue HTTP Requests: Issue HTTP Requests:
httprl_build_url_self() httprl_build_url_self()
- Helper function to build an URL for asynchronous requests to self. - Helper function to build an URL for asynchronous requests to self. Note that
you should set the Host name in the headers when using this.
httprl_request() httprl_request()
- Queue up a HTTP request in httprl_send_request(). - Queue up a HTTP request in httprl_send_request().
httprl_send_request() httprl_send_request()
...@@ -141,13 +142,19 @@ Request http://drupal.org/robots.txt and save it to tmp folder. ...@@ -141,13 +142,19 @@ Request http://drupal.org/robots.txt and save it to tmp folder.
Request this servers own front page & the node page. Request this servers own front page & the node page.
<?php <?php
$options = array(
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Build URL to point to front page of this server. // Build URL to point to front page of this server.
$url_front = httprl_build_url_self(); $url_front = httprl_build_url_self();
// Build URL to point to /node on this server. // Build URL to point to /node on this server.
$url_node = httprl_build_url_self('node'); $url_node = httprl_build_url_self('node');
// Queue up the requests. // Queue up the requests.
httprl_request($url_front); httprl_request($url_front, $options);
httprl_request($url_node); httprl_request($url_node, $options);
// Execute requests. // Execute requests.
$request = httprl_send_request(); $request = httprl_send_request();
...@@ -165,6 +172,10 @@ this should generate 10 404s and the $request object won't contain much info. ...@@ -165,6 +172,10 @@ this should generate 10 404s and the $request object won't contain much info.
// Set the blocking mode. // Set the blocking mode.
$options = array( $options = array(
'blocking' => FALSE, 'blocking' => FALSE,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Queue up the requests. // Queue up the requests.
$max = 10; $max = 10;
...@@ -189,6 +200,10 @@ URLs will all have the same options. ...@@ -189,6 +200,10 @@ URLs will all have the same options.
$options = array( $options = array(
'method' => 'HEAD', 'method' => 'HEAD',
'blocking' => FALSE, 'blocking' => FALSE,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Queue up the requests. // Queue up the requests.
$max = 10; $max = 10;
...@@ -218,6 +233,10 @@ connections that couldn't be made will be dropped. ...@@ -218,6 +233,10 @@ connections that couldn't be made will be dropped.
'blocking' => FALSE, 'blocking' => FALSE,
'domain_connections' => 1000, 'domain_connections' => 1000,
'global_connections' => 1000, 'global_connections' => 1000,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Queue up the requests. // Queue up the requests.
$max = 1000; $max = 1000;
...@@ -251,6 +270,10 @@ connection to be established; `async_connect` is FALSE. ...@@ -251,6 +270,10 @@ connection to be established; `async_connect` is FALSE.
// clients. // clients.
'domain_connections' => 32, 'domain_connections' => 32,
'global_connections' => 1000, 'global_connections' => 1000,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Queue up the requests. // Queue up the requests.
$max = 1000; $max = 1000;
...@@ -286,6 +309,10 @@ we are going to use httprl_pr() as the callback function. ...@@ -286,6 +309,10 @@ we are going to use httprl_pr() as the callback function.
'return' => &$x, 'return' => &$x,
), ),
), ),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Build URL to point to front page of this server. // Build URL to point to front page of this server.
$url_front = httprl_build_url_self(); $url_front = httprl_build_url_self();
...@@ -315,6 +342,10 @@ background callback creates a new thread to run this function in. ...@@ -315,6 +342,10 @@ background callback creates a new thread to run this function in.
'return' => &$x, 'return' => &$x,
), ),
), ),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Build URL to point to front page of this server. // Build URL to point to front page of this server.
$url_front = httprl_build_url_self(); $url_front = httprl_build_url_self();
...@@ -349,6 +380,10 @@ instead of returning a value. ...@@ -349,6 +380,10 @@ instead of returning a value.
), ),
FALSE, FALSE,
), ),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Build URL to point to front page of this server. // Build URL to point to front page of this server.
$url_front = httprl_build_url_self(); $url_front = httprl_build_url_self();
...@@ -425,8 +460,6 @@ the first and last 128 bytes are returned. ...@@ -425,8 +460,6 @@ the first and last 128 bytes are returned.
Send 2 files in one field via a POST request. Send 2 files in one field via a POST request.
<?php <?php
// Send request to front page.
$url_front = httprl_build_url_self();
// Set options. // Set options.
$options = array( $options = array(
'method' => 'POST', 'method' => 'POST',
...@@ -441,7 +474,14 @@ Send 2 files in one field via a POST request. ...@@ -441,7 +474,14 @@ Send 2 files in one field via a POST request.
), ),
), ),
), ),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
); );
// Send request to front page.
$url_front = httprl_build_url_self();
// Queue up the request. // Queue up the request.
httprl_request($url_front, $options); httprl_request($url_front, $options);
// Execute request. // Execute request.
......
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