You are here

function httprl_parse_url in HTTP Parallel Request & Threading Library 6

Same name and namespace in other branches
  1. 7 httprl.module \httprl_parse_url()

Run parse_url and handle any errors.

Parameters

string $url: String containing the URL to be parsed by parse_url().

object &$result: Result object; used only for error handling in this function.

Return value

array Array from parse_url().

1 call to httprl_parse_url()
httprl_request in ./httprl.module
Queue up a HTTP request in httprl_send_request.

File

./httprl.module, line 488
HTTP Parallel Request Library module.

Code

function httprl_parse_url($url, &$result) {

  // Parse the URL and make sure we can handle the schema.
  $uri = @parse_url($url);

  // If the t function is not available use httprl_pr.
  $t = function_exists('t') ? 't' : 'httprl_pr';
  if (empty($uri)) {

    // Set error code for failed request.
    $result->error = $t('Unable to parse URL.');
    $result->code = HTTPRL_URL_PARSE_ERROR;
  }
  elseif (!isset($uri['scheme'])) {

    // Set error code for failed request.
    $result->error = $t('Missing schema.');
    $result->code = HTTPRL_URL_MISSING_SCHEMA;
  }
  return $uri;
}