Issue #3059391 by Liam Morland: Use drupal_http_build_query() in drupal_http_request()
parent
ac4277fede
commit
ff3c4ca5bf
|
@ -762,8 +762,8 @@ function drupal_access_denied() {
|
|||
* - method: A string containing the request method. Defaults to 'GET'.
|
||||
* - data: An array or object containing the values for the request body or a
|
||||
* string containing the request body, formatted as
|
||||
* 'param=value¶m=value&...'; to generate this, use http_build_query().
|
||||
* Defaults to NULL.
|
||||
* 'param=value¶m=value&...'; to generate this, use
|
||||
* drupal_http_build_query(). Defaults to NULL.
|
||||
* - max_redirects: An integer representing how many times a redirect
|
||||
* may be followed. Defaults to 3.
|
||||
* - timeout: A float representing the maximum number of seconds the function
|
||||
|
@ -789,7 +789,7 @@ function drupal_access_denied() {
|
|||
* easy access the array keys are returned in lower case.
|
||||
* - data: A string containing the response body that was received.
|
||||
*
|
||||
* @see http_build_query()
|
||||
* @see drupal_http_build_query()
|
||||
*/
|
||||
function drupal_http_request($url, array $options = array()) {
|
||||
// Allow an alternate HTTP client library to replace Drupal's default
|
||||
|
@ -933,7 +933,7 @@ function drupal_http_request($url, array $options = array()) {
|
|||
|
||||
// Convert array or object $options['data'] to query string.
|
||||
if (is_array($options['data']) || is_object($options['data'])) {
|
||||
$options['data'] = http_build_query($options['data']);
|
||||
$options['data'] = drupal_http_build_query($options['data']);
|
||||
}
|
||||
|
||||
// Only add Content-Length if we actually have any content or if it is a POST
|
||||
|
|
|
@ -1125,8 +1125,8 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
|
|||
$this->assertEqual($unable_to_parse->error, 'unable to parse URL', 'Returned with "unable to parse URL" error message.');
|
||||
|
||||
// Fetch page and check that the data parameter works with both array and string.
|
||||
$data_array = array($this->randomName() => $this->randomName());
|
||||
$data_string = http_build_query($data_array);
|
||||
$data_array = array($this->randomName() => $this->randomString() . ' "\'');
|
||||
$data_string = drupal_http_build_query($data_array);
|
||||
$result = drupal_http_request(url('node', array('absolute' => TRUE)), array('data' => $data_array));
|
||||
$this->assertEqual($result->code, 200, 'Fetched page successfully.');
|
||||
$this->assertTrue(substr($result->request, -strlen($data_string)) === $data_string, 'Request ends with URL-encoded data when drupal_http_request() called using array.');
|
||||
|
|
Loading…
Reference in New Issue