You are here

function ServicesWebTestCase::parseHeader in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesWebTestCase.php \ServicesWebTestCase::parseHeader()

Parse header.

Parameters

type $content:

Return value

type

7 calls to ServicesWebTestCase::parseHeader()
ServicesSecurityTests::servicesPostNoCSRFHeader in tests/functional/ServicesSecurityTests.test
Copy of servicesPost method but without CSRF header.
ServicesWebTestCase::servicesDelete in tests/services.test
Perform DELETE request.
ServicesWebTestCase::servicesGet in tests/services.test
Perform GET request.
ServicesWebTestCase::servicesHead in tests/services.test
Perform HEAD request.
ServicesWebTestCase::servicesPost in tests/services.test
Perform POST request.

... See full list

File

tests/services.test, line 251

Class

ServicesWebTestCase

Code

function parseHeader($content, $call_type = 'php') {
  $info = curl_getinfo($this->curlHandle);
  $header = drupal_substr($content, 0, $info['header_size']);
  $header = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $header);
  $status = strtok($header, "\r\n");
  $code = $info['http_code'];
  $raw_body = drupal_substr($content, $info['header_size'], drupal_strlen($content) - $info['header_size']);
  switch ($call_type) {
    case 'php':
      $body = unserialize($raw_body);
      break;
    case 'json':
      $body = json_decode($raw_body);
      break;
  }
  return array(
    $info,
    $header,
    $status,
    $code,
    $body,
  );
}