if (!(connection instanceof HttpURLConnection)) {
throw new IllegalArgumentException(feedUrl.toExternalForm() + " is not a valid HTTP Url");
}
HttpURLConnection httpConnection = (HttpURLConnection)connection;
SyndFeedInfo syndFeedInfo = null;
if (dtsFeedInfo != null) {
setRequestHeaders(connection, dtsFeedInfo.getLastModified(), dtsFeedInfo.getETag());
}
else {
setRequestHeaders(connection, null, null);
}
httpConnection.connect();
try {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
if (dtsFeedInfo == null) {
// this is a feed that hasn't been retrieved
syndFeedInfo = new SyndFeedInfo();
try {
resetFeedInfo(feedUrl, syndFeedInfo, httpConnection);
}
catch (java.lang.IllegalArgumentException e) {
logger.warning("Got exception " + e.getMessage());
logger.warning("If " + feedUrl + " was a correctly formed Twitter feed, this error is likely due to having the max number of requests for the current hour exceeded");
throw e;
}
}
else {
// check the response code
int responseCode = httpConnection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
logger.fine("*****the feed " + feedUrl + " needs retrieving");
syndFeedInfo = new SyndFeedInfo();
resetFeedInfo(feedUrl, syndFeedInfo, httpConnection);
}
else {
logger.fine("the feed " + feedUrl + " does not need retrieving");
// the feed does not need retrieving