# HG changeset patch # User stechong # Date 1239647660 18000 # Node ID 6c6d4b0c9171ffc0850144da7889bbe7d10f716e # Parent 8839c373a1c1ff14907f4891aba0b3470745c14c Specifies acceptable content types in connection request header; fix for Bug 8775. diff -r 8839c373a1c1 -r 6c6d4b0c9171 core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/CarbideFeedFetcher.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/CarbideFeedFetcher.java Mon Apr 13 13:34:20 2009 -0500 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.internal.news.reader.feed; + +import java.net.URLConnection; + +import com.sun.syndication.fetcher.impl.FeedFetcherCache; +import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher; +import com.sun.syndication.fetcher.impl.SyndFeedInfo; + +/** + * A class to retrieve feed via HTTP connection. + * + */ +public class CarbideFeedFetcher extends HttpURLFeedFetcher { + + /** + * Constructor to enable CarbideFeedFetcher without caching feeds. + */ + public CarbideFeedFetcher() { + super(); + } + + /** + * Constructor to enable CarbideFeedFetcher to cache feeds + * @param feedCache - an instance of the FeedFetcherCache interface + */ + public CarbideFeedFetcher(FeedFetcherCache feedInfoCache) { + super(feedInfoCache); + } + + /* + * (non-Javadoc) + * @see com.sun.syndication.fetcher.impl.HttpURLFeedFetcher#setRequestHeaders(java.net.URLConnection, com.sun.syndication.fetcher.impl.SyndFeedInfo) + */ + protected void setRequestHeaders(URLConnection connection, SyndFeedInfo syndFeedInfo) { + super.setRequestHeaders(connection, syndFeedInfo); + // specify acceptable content types + connection.setRequestProperty("Accept", "*/xml"); + } + +} diff -r 8839c373a1c1 -r 6c6d4b0c9171 core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java --- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java Fri Apr 10 14:02:22 2009 -0500 +++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java Mon Apr 13 13:34:20 2009 -0500 @@ -333,7 +333,7 @@ } FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance(); - FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache); + FeedFetcher fetcher = new CarbideFeedFetcher(feedInfoCache); SyndFeed sFeed = fetcher.retrieveFeed(feedUrl); CarbideSyndFeed feed = new CarbideSyndFeed(sFeed); if (feed != null) {