System.setProperty("httpclient.useragent", "Openfire Admin Console: v" +
XMPPServer.getInstance().getServerInfo().getVersion().getVersionString());
String urlStr = feedUrl.toString();
FeedFetcherCache cache = getFeedInfoCache();
if (cache != null) {
// retrieve feed
HttpMethod method = new GetMethod(urlStr);
method.addRequestHeader("Accept-Encoding", "gzip");
try {
if (isUsingDeltaEncoding()) {
method.setRequestHeader("A-IM", "feed");
}
// get the feed info from the cache
// Note that syndFeedInfo will be null if it is not in the cache
SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
if (syndFeedInfo != null) {
method.setRequestHeader("If-None-Match", syndFeedInfo.getETag());
if (syndFeedInfo.getLastModified() instanceof String) {
method.setRequestHeader("If-Modified-Since", (String)syndFeedInfo.getLastModified());
}
}
method.setFollowRedirects(true);
int statusCode = client.executeMethod(method);
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, urlStr);
handleErrorCodes(statusCode);
SyndFeed feed = getFeed(syndFeedInfo, urlStr, method, statusCode);
syndFeedInfo = buildSyndFeedInfo(feedUrl, urlStr, method, feed, statusCode);
cache.setFeedInfo(new URL(urlStr), syndFeedInfo);
// the feed may have been modified to pick up cached values
// (eg - for delta encoding)
feed = syndFeedInfo.getSyndFeed();