You are here

function cf_http_validate_response in Common Functionality 7

Same name and namespace in other branches
  1. 7.2 modules/cf_http/cf_http.module \cf_http_validate_response()

Validate http responses by checking header.

Originally From: http://php.net/manual/en/function.fsockopen.php#85572

Why: Custom php scripts need a straight-forward and easy way to pull data from another website. This is useful as an alternative to iframe and has advantages and disadvantages to iframes. An advantage is that this allows showing remote content even if the remote url is down (via caching). A disadvantage is that remote images and links need to be processed, updated, and possibly even manually cached.

Parameters

array $headers: An array of http headers to validate.

array $function_history: (optional) An array of function names, ie: array('0' => 'my_function_name').

Return value

bool A boolean with TRUE representing that the headers are valid, FALSE otherwise.

1 call to cf_http_validate_response()
cf_http_parse_response in modules/cf_http/cf_http.module
Accepts and processes provided http content.

File

modules/cf_http/cf_http.module, line 120

Code

function cf_http_validate_response(array $headers, array $function_history = array()) {
  if (empty($headers)) {
    return FALSE;
  }
  switch (trim(strtolower($headers[0]))) {
    case 'http/1.0 100 ok':
    case 'http/1.0 200 ok':
    case 'http/1.1 100 ok':
    case 'http/1.1 200 ok':
      return TRUE;
  }
  return FALSE;
}