Commit 4bb37b44 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 37c7203b
......@@ -65,7 +65,8 @@ API OVERVIEW
Issue HTTP Requests:
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()
- Queue up a HTTP request in httprl_send_request().
httprl_send_request()
......@@ -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.
<?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.
$url_front = httprl_build_url_self();
// Build URL to point to /node on this server.
$url_node = httprl_build_url_self('node');
// Queue up the requests.
httprl_request($url_front);
httprl_request($url_node);
httprl_request($url_front, $options);
httprl_request($url_node, $options);
// Execute requests.
$request = httprl_send_request();
......@@ -165,6 +172,10 @@ this should generate 10 404s and the $request object won't contain much info.
// Set the blocking mode.
$options = array(
'blocking' => FALSE,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Queue up the requests.
$max = 10;
......@@ -189,6 +200,10 @@ URLs will all have the same options.
$options = array(
'method' => 'HEAD',
'blocking' => FALSE,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Queue up the requests.
$max = 10;
......@@ -218,6 +233,10 @@ connections that couldn't be made will be dropped.
'blocking' => FALSE,
'domain_connections' => 1000,
'global_connections' => 1000,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Queue up the requests.
$max = 1000;
......@@ -251,6 +270,10 @@ connection to be established; `async_connect` is FALSE.
// clients.
'domain_connections' => 32,
'global_connections' => 1000,
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Queue up the requests.
$max = 1000;
......@@ -286,6 +309,10 @@ we are going to use httprl_pr() as the callback function.
'return' => &$x,
),
),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Build URL to point to front page of this server.
$url_front = httprl_build_url_self();
......@@ -315,6 +342,10 @@ background callback creates a new thread to run this function in.
'return' => &$x,
),
),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Build URL to point to front page of this server.
$url_front = httprl_build_url_self();
......@@ -349,6 +380,10 @@ instead of returning a value.
),
FALSE,
),
'headers' => array(
// Set the Host header to self.
'Host' => $_SERVER['HTTP_HOST'],
),
);
// Build URL to point to front page of this server.
$url_front = httprl_build_url_self();
......@@ -425,8 +460,6 @@ the first and last 128 bytes are returned.
Send 2 files in one field via a POST request.
<?php
// Send request to front page.
$url_front = httprl_build_url_self();
// Set options.
$options = array(
'method' => 'POST',
......@@ -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.
httprl_request($url_front, $options);
// 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