function httprl_build_request_string in HTTP Parallel Request & Threading Library 6
Same name and namespace in other branches
- 7 httprl.module \httprl_build_request_string()
Build the request string.
This string is what gets sent to the server once a connection has been made.
Parameters
array $uri: Array from parse_url().
array $options: Array containing options.
Return value
string String containing the data that will be written to the server.
1 call to httprl_build_request_string()
- httprl_request in ./
httprl.module - Queue up a HTTP request in httprl_send_request.
File
- ./
httprl.module, line 905 - HTTP Parallel Request Library module.
Code
function httprl_build_request_string($uri, $options) {
// Construct the path to act on.
// Enocde any spaces to be %20.
$path = isset($uri['path']) ? str_replace(' ', $options['url_encoding']['space']['path'], $uri['path']) : '/';
if (isset($uri['query'])) {
// Enocde any spaces in the query string to be %20.
$path .= '?' . str_replace(' ', $options['url_encoding']['space']['query'], $uri['query']);
}
// Assemble the request together. HTTP version requires to be a float.
$request = $options['method'] . ' ' . $path . ' HTTP/' . sprintf("%.1F", $options['version']) . "\r\n";
foreach ($options['headers'] as $name => $value) {
$request .= $name . ': ' . trim($value) . "\r\n";
}
return $request . "\r\n" . $options['data'];
}