mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-24 13:05:38 +00:00
cleanup
This commit is contained in:
@@ -50,20 +50,20 @@ public class FeedFetcher {
|
||||
log.debug("Fetching feed {}", feedUrl);
|
||||
|
||||
HttpResult result = getter.get(HttpRequest.builder(feedUrl).lastModified(lastModified).eTag(eTag).build());
|
||||
byte[] content = result.getContent();
|
||||
byte[] content = result.content();
|
||||
|
||||
FeedParserResult parserResult;
|
||||
try {
|
||||
parserResult = parser.parse(result.getUrlAfterRedirect(), content);
|
||||
parserResult = parser.parse(result.urlAfterRedirect(), content);
|
||||
} catch (FeedParsingException e) {
|
||||
if (extractFeedUrlFromHtml) {
|
||||
String extractedUrl = extractFeedUrl(urlProviders, feedUrl, new String(result.getContent(), StandardCharsets.UTF_8));
|
||||
String extractedUrl = extractFeedUrl(urlProviders, feedUrl, new String(result.content(), StandardCharsets.UTF_8));
|
||||
if (StringUtils.isNotBlank(extractedUrl)) {
|
||||
feedUrl = extractedUrl;
|
||||
|
||||
result = getter.get(HttpRequest.builder(extractedUrl).lastModified(lastModified).eTag(eTag).build());
|
||||
content = result.getContent();
|
||||
parserResult = parser.parse(result.getUrlAfterRedirect(), content);
|
||||
content = result.content();
|
||||
parserResult = parser.parse(result.urlAfterRedirect(), content);
|
||||
} else {
|
||||
throw new NoFeedFoundException(e);
|
||||
}
|
||||
@@ -76,26 +76,24 @@ public class FeedFetcher {
|
||||
throw new IOException("Feed content is empty.");
|
||||
}
|
||||
|
||||
boolean lastModifiedHeaderValueChanged = !Strings.CS.equals(lastModified, result.getLastModifiedSince());
|
||||
boolean etagHeaderValueChanged = !Strings.CS.equals(eTag, result.getETag());
|
||||
boolean lastModifiedHeaderValueChanged = !Strings.CS.equals(lastModified, result.lastModifiedSince());
|
||||
boolean etagHeaderValueChanged = !Strings.CS.equals(eTag, result.eTag());
|
||||
|
||||
String hash = Digests.sha1Hex(content);
|
||||
if (lastContentHash != null && lastContentHash.equals(hash)) {
|
||||
log.debug("content hash not modified: {}", feedUrl);
|
||||
throw new NotModifiedException("content hash not modified",
|
||||
lastModifiedHeaderValueChanged ? result.getLastModifiedSince() : null,
|
||||
etagHeaderValueChanged ? result.getETag() : null);
|
||||
throw new NotModifiedException("content hash not modified", lastModifiedHeaderValueChanged ? result.lastModifiedSince() : null,
|
||||
etagHeaderValueChanged ? result.eTag() : null);
|
||||
}
|
||||
|
||||
if (lastPublishedDate != null && lastPublishedDate.equals(parserResult.lastPublishedDate())) {
|
||||
log.debug("publishedDate not modified: {}", feedUrl);
|
||||
throw new NotModifiedException("publishedDate not modified",
|
||||
lastModifiedHeaderValueChanged ? result.getLastModifiedSince() : null,
|
||||
etagHeaderValueChanged ? result.getETag() : null);
|
||||
throw new NotModifiedException("publishedDate not modified", lastModifiedHeaderValueChanged ? result.lastModifiedSince() : null,
|
||||
etagHeaderValueChanged ? result.eTag() : null);
|
||||
}
|
||||
|
||||
return new FeedFetcherResult(parserResult, result.getUrlAfterRedirect(), result.getLastModifiedSince(), result.getETag(), hash,
|
||||
result.getValidFor());
|
||||
return new FeedFetcherResult(parserResult, result.urlAfterRedirect(), result.lastModifiedSince(), result.eTag(), hash,
|
||||
result.validFor());
|
||||
}
|
||||
|
||||
private static String extractFeedUrl(List<FeedURLProvider> urlProviders, String url, String urlContent) {
|
||||
|
||||
Reference in New Issue
Block a user