/** * <p> * Set appropriate HTTP headers, including conditional get and gzip encoding headers * </p> * * @param connection A URLConnection * @param syndFeedInfo The SyndFeedInfo for the feed to be retrieved. May be null * @param userAgent the name of the user-agent to be placed in HTTP-header. */ protected void setRequestHeaders(final URLConnection connection, final SyndFeedInfo syndFeedInfo, final String userAgent) { if (syndFeedInfo != null) { // set the headers to get feed only if modified // we support the use of both last modified and eTag headers if (syndFeedInfo.getLastModified() != null) { final Object lastModified = syndFeedInfo.getLastModified(); if (lastModified instanceof Long) { connection.setIfModifiedSince((Long) syndFeedInfo.getLastModified()); } } if (syndFeedInfo.getETag() != null) { connection.setRequestProperty("If-None-Match", syndFeedInfo.getETag()); } } // header to retrieve feed gzipped connection.setRequestProperty("Accept-Encoding", "gzip"); connection.addRequestProperty("User-Agent", userAgent); if (isUsingDeltaEncoding()) { connection.addRequestProperty("A-IM", "feed"); } }
public DeltaSyndFeedInfo(final SyndFeedInfo backingFeedInfo) { setETag(backingFeedInfo.getETag()); setId(backingFeedInfo.getId()); setLastModified(backingFeedInfo.getLastModified()); setSyndFeed(backingFeedInfo.getSyndFeed()); }
public DeltaSyndFeedInfo(final SyndFeedInfo backingFeedInfo) { setETag(backingFeedInfo.getETag()); setId(backingFeedInfo.getId()); setLastModified(backingFeedInfo.getLastModified()); setSyndFeed(backingFeedInfo.getSyndFeed()); }
try { SyndFeedInfo feedInfo = feedCache.getFeedInfo(new URL(newSub.getFeedURL())); if(feedInfo.getLastModified() != null) { long lastUpdatedLong = (Long) feedInfo.getLastModified(); if (lastUpdatedLong != 0) { newSub.setLastUpdated(new Date(lastUpdatedLong));
final Object lastModifiedHeader = syndFeedInfo.getLastModified(); if (lastModifiedHeader instanceof String) { method.setRequestHeader("If-Modified-Since", (String) lastModifiedHeader);