You are here

function httprl_extract_background_callback_data in HTTP Parallel Request & Threading Library 7

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

Extract background callback data.

Set the return and printed values & any pass by reference values from a background callback operation.

Parameters

object $result: An object from httprl_send_request.

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

File

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

Code

function httprl_extract_background_callback_data(&$result) {

  // Extract data from string.
  $data = array();
  parse_str($result->data, $data);

  // Follow rfc4648 for base64url
  // @see http://tools.ietf.org/html/rfc4648#page-7
  $serialized_string = trim(base64_decode(strtr(current($data), array(
    '-' => '+',
    '_' => '/',
  ))));
  $data = @unserialize($serialized_string);
  if ($data !== 'b:0;' && $data === FALSE) {
    return;
  }

  // Set return and printed values.
  if (isset($data['return'])) {
    $result->options['internal_states']['background_function_return'] = $data['return'];
  }
  if (isset($data['printed'])) {
    $result->options['internal_states']['background_function_printed'] = $data['printed'];
  }

  // Set any pass by reference values.
  if (isset($data['args'])) {
    httprl_recursive_array_reference_extract($result->options['internal_states']['background_function_args'], $data['args']);
  }
}