public static function load_resource($project_url, $ticket, $path)
{
$url = fix_parse_url($project_url);
$response = SimpleHTTP::send('POST', $url['host'], $url['port'], $url['path'], array('a' => 'load_resource', 'ticket' => $ticket, 'path' => $path));
if ('200' != $response['status_code']) {
throw new Exception("Invalid status code `{$response['status_code']}' returned from server `{$url['host']}'.");
}
$content = trim($response['body']);
// AmyLogger::logn($content);
if ('' === $content) {
throw new Exception("Unable to load project resource, no content returned from `{$url['host']}{$url['path']}'.");
}
if (false !== strpos($response['headers']['content-type'], 'text/xml')) {
return array('flush' => true, 'content' => $content);
}
if ('#S#' != substr($content, 0, 3)) {
throw new Exception("Error while loading project resource: Message from {$url['host']}{$url['path']}: " . substr($content, 3));
}
return array('flush' => false, 'content' => substr($content, 3));
}