feed = malloc( sizeof(Feed) );
g_return_val_if_fail(feed != NULL, NULL);
+ feed->is_valid = TRUE;
feed->timeout = FEED_DEFAULT_TIMEOUT;
feed->url = g_strdup(url);
feed->auth = NULL;
if( res != CURLE_OK ) {
feed->fetcherr = g_strdup(curl_easy_strerror(res));
response_code = FEED_ERR_FETCH;
- } else
+ } else if (!feed->is_valid) {
+ response_code = FEED_ERR_NOFEED;
+ } else {
curl_easy_getinfo(eh, CURLINFO_RESPONSE_CODE, &response_code);
+ }
cleanup:
curl_easy_cleanup(eh);
feedtype = FEED_TYPE_ATOM_10;
else
feedtype = FEED_TYPE_ATOM_03;
+ } else {
+ /* Not a known feed type */
+ ctx->feed->is_valid = FALSE;
}
}
FeedParserCtx *ctx = (FeedParserCtx *)data;
gint status, err;
+ if (!ctx->feed->is_valid) {
+ /* We already know that the feed is not valid, so we won't
+ * try parsing it. Just return correct number so libcurl is
+ * happy. */
+ return len;
+ }
+
status = XML_Parse(ctx->parser, ptr, len, FALSE);
if( status == XML_STATUS_ERROR ) {
err = XML_GetErrorCode(ctx->parser);
printf("\nExpat: --- %s\n\n", XML_ErrorString(err));
+ ctx->feed->is_valid = FALSE;
}
return len;
ctx->success = FALSE;
} else {
- if( ctx->feed == NULL ) {
+ if( ctx->feed == NULL || ctx->response_code == FEED_ERR_NOFEED) {
if( verbose & RSSYL_SHOW_ERRORS) {
gchar *msg = g_markup_printf_escaped(
(const char *) _("No valid feed found at\n<b>%s</b>"),