function http_request_check_result in Feeds 7.2
Checks the result of the HTTP Request.
Parameters
string $url: The URL that was requested.
object $result: The HTTP Request result.
Throws
FeedsHTTPRequestException In case the result code of the HTTP request is not in the 2xx series.
2 calls to http_request_check_result()
- FeedsEnclosure::getContent in plugins/
FeedsParser.inc - Downloads the content from the file URL.
- FeedsHTTPFetcherResult::getRaw in plugins/
FeedsHTTPFetcher.inc - Overrides FeedsFetcherResult::getRaw().
File
- libraries/
http_request.inc, line 374 - Download via HTTP.
Code
function http_request_check_result($url, $result) {
if (!in_array($result->code, array(
200,
201,
202,
203,
204,
205,
206,
))) {
$vars = array(
'@url' => $url,
'@code' => $result->code,
'@error' => isset($result->error) ? $result->error : 'Unknown error',
);
switch ($result->code) {
case FEEDS_ERROR_PARSE_ERROR:
$message = t('Download of @url failed because it could not be parsed.', $vars);
break;
case FEEDS_ERROR_NO_SCHEME:
$message = t("Download of @url failed because its scheme could not be determined. The URL is expected to start with something like '@example'.", $vars + array(
'@example' => 'http://',
));
break;
case FEEDS_ERROR_INVALID_SCHEME:
$message = t('Download of @url failed because its scheme is not supported: @error. Examples of supported schemes are: @supported.', $vars + array(
'@supported' => implode(', ', array(
'http',
'https',
)),
));
break;
default:
if (isset($result->error)) {
$message = t('Download of @url failed with code @code and the following error: @error.', $vars);
}
else {
$message = t('Download of @url failed with code @code.', $vars);
}
break;
}
throw new FeedsHTTPRequestException($message);
}
}