You are here

function httprl_reconstruct_redirects in HTTP Parallel Request & Threading Library 7

Same name and namespace in other branches
  1. 6 httprl.module \httprl_reconstruct_redirects()

Reconstruct the internal redirect arrays.

Parameters

object $result: An object from httprl_send_request.

1 call to httprl_reconstruct_redirects()
httprl_post_processing in ./httprl.module
Run post processing on the request if we are done reading.

File

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

Code

function httprl_reconstruct_redirects(&$result) {

  // Return if original_url is not set.
  if (empty($result->options['internal_states']['original_url'])) {
    return;
  }

  // Set the original url.
  $result->url = $result->options['internal_states']['original_url'];

  // Set the redirect code.
  $result->redirect_code_array = $result->options['internal_states']['redirect_code_array'];
  $result->redirect_code = array_pop($result->options['internal_states']['redirect_code_array']);

  // Set the redirect url.
  $result->redirect_url_array = $result->options['internal_states']['redirect_url_array'];
  $result->redirect_url = array_pop($result->options['internal_states']['redirect_url_array']);

  // Cleanup.
  unset($result->options['internal_states']['original_url'], $result->options['internal_states']['redirect_code_array'], $result->options['internal_states']['redirect_url_array']);
  if (empty($result->options['internal_states'])) {
    unset($result->options['internal_states']);
  }
}