Commit 1a146322 authored by mikeytown2's avatar mikeytown2

Issue #2822115: configurable url encoding of the url in the request body

parent 3c47107c
......@@ -537,6 +537,7 @@ function httprl_set_default_options(array &$options) {
'chunk_size_write' => 1024,
'async_connect' => TRUE,
'ping_db' => 20,
'url_encoding' => array(),
);
// Adjust Time To First Byte Timeout if timeout is large and ttfb is default.
......@@ -556,6 +557,16 @@ function httprl_set_default_options(array &$options) {
'Connection' => 'close',
);
// Defaults for url encoding the url.
// Use %20 for spaces in the path and in the query string.
$options['url_encoding'] += array(
'space' => array(),
);
$options['url_encoding']['space'] += array(
'path' => '%20',
'query' => '%20',
);
// Set referrer to current page.
if (!isset($options['headers']['Referer']) && !empty($options['referrer'])) {
if (function_exists('request_uri')) {
......@@ -891,9 +902,11 @@ function httprl_basic_auth($uri, &$options) {
*/
function httprl_build_request_string($uri, $options) {
// Construct the path to act on.
$path = isset($uri['path']) ? $uri['path'] : '/';
// Enocde any spaces to be %20.
$path = isset($uri['path']) ? str_replace(' ', $options['url_encoding']['space']['path'], $uri['path']) : '/';
if (isset($uri['query'])) {
$path .= '?' . $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.
......
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