Git Product home page Git Product logo

feedreader's Introduction

FeedReader

FeedReader is a .net library used for reading and parsing RSS and ATOM feeds. Supports RSS 0.91, 0.92, 1.0, 2.0 and ATOM. Developed because tested existing libraries do not work with different languages, encodings or have other issues. Library tested with multiple languages, encodings and feeds.

FeedReader library is available as NuGet package: https://www.nuget.org/packages/CodeHollow.FeedReader/

Usage

The simplest way to read a feed and show the information is:

    var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");

    Console.WriteLine("Feed Title: " + feed.Title);
    Console.WriteLine("Feed Description: " + feed.Description);
    Console.WriteLine("Feed Image: " + feed.ImageUrl);
    // ...
    foreach(var item in feed.Items)
    {
        Console.WriteLine(item.Title + " - " + item.Link);
    }

There are some properties that are only available in e.g. RSS 2.0. If you want to get those properties, the property "SpecificFeed" is the right one:

    var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");

    Console.WriteLine("Feed Title: " + feed.Title);
            
    if(feed.Type == FeedType.Rss_2_0)
    {
        var rss20feed = (Feeds.Rss20Feed)feed.SpecificFeed;
        Console.WriteLine("Generator: " + rss20feed.Generator);
    }

If the url to the feed is not known, then you can use FeedReader.GetFeedUrlsFromUrl(url) to parse the url from the html webpage:

    string url = "arminreiter.com";
    var urls = FeedReader.GetFeedUrlsFromUrl(url);
            
    string feedUrl;
    if (urls.Count() < 1) // no url - probably the url is already the right feed url
        feedUrl = url;
    else if (urls.Count() == 1)
        feedUrl = urls.First().Url;
    else if (urls.Count() == 2) // if 2 urls, then its usually a feed and a comments feed, so take the first per default
        feedUrl = urls.First().Url;
    else
    {
        // show all urls and let the user select (or take the first or ...)
        // ...
    }

    var readerTask = FeedReader.ReadAsync(feedUrl);
    readerTask.ConfigureAwait(false);

    foreach (var item in readerTask.Result.Items)
    {
        Console.WriteLine(item.Title + " - " + item.Link);
        // ...
    }

The code contains a sample console application: https://github.com/codehollow/FeedReader/tree/master/FeedReader.ConsoleSample

Specifications

feedreader's People

Contributors

adrientoub avatar arminreiter avatar asapha avatar asimonov-im avatar atakane avatar ceemafour avatar codehollow avatar cwellborn-evestment avatar eallegretta avatar emilast avatar inyutin-maxim avatar mika-s avatar tsmgeek avatar viktor-ramin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

feedreader's Issues

Async Issue

Hello!
When trying to use your FeedReader in UWP-type application the app deadlocks.
I made all necessary changes to the code so it works, but I don't know how to commit here.
I'll leave a link to OneDrive, where the folder with the project is.
https://1drv.ms/f/s!AtuQdKOJRdhQgegqnpHHrZgnwRQZfw
Best wishes,
Tim

How can I parse enclosure data from a feed?

Hey, I'm using your library to parse podcast feeds such as this one.

When I read the feed with FeedReader.ReadAsync and inspect the items I can't see the enclosure mp3 data.

Do you know why this is?

A quick search of your repo I can see you handle enclosure data in FeedItemEnclosure.cs class so I'm not sure if I'm doing something wrong?

Thanks for the great library!

HtmlAgilityPack Dependency

Hi, it looks like the library uses native XDocument (System.Xml.Linq) for parsing the feeds, but also has a dependency on HtmlAgilityPack to fetch & parse HTML I suppose.

Is there a way to remove or separate the dependency on HtmlAgilityPack, as we don't use it nor need it as part of our project like many other users? We can just inject feed data using FeedReader.ReadFromString.

I guess we can run Install-Package CodeHollow.FeedReader -IgnoreDependencies to install the nuget package without dependencies, but I'm not sure if it will compile and if package restore at build time will work the same.

How to find images in Feed items

Hello, @CodeHollow!

I was wondering how you can find the images in the Feed items.
I've added 2 feed examples since the adding of images can vary per feed as i've discovered.

Examples:

https://www.volkskrant.nl/sport/rss.xml > Meda:content

<media:content type="image/jpeg" url="https://static0.persgroep.net/volkskrant/image/e84c5459-7f38-4731-b94f-259042548f04?width=397&amp;height=289">
<media:thumbnail url="https://static0.persgroep.net/volkskrant/image/e84c5459-7f38-4731-b94f-259042548f04?width=397&amp;height=289" />
</media:content>

http://www.nu.nl/rss/algemeen > Enclosure

Error in .net core 2.1

Getting following error in net core 2.1. Code work on .net framework.

'br' start tag on line #### position ## does not match end tag of 'font'

Ignores if url contains encoding character

I am trying to parse Stackoverflow rss feed, but feed url contains %23 for C#

string URL1 = "https://stackoverflow.com/feeds/tag?tagnames=c%23&sort=newest";
Feed feed = await FeedReader.ReadAsync(URL1);

I tried with @

string URL1 =@"https://stackoverflow.com/feeds/tag?tagnames=c%23&sort=newest";

still ignores %23 and shows C feeds

AutoRedirect: Also handle relative location path correctly

Hi,

when using autoRedirect there is a problem with relative urls, because there are some feeds that
are using relative urls in the Location-Header since this is also valid:

https://www.tagesschau.de/xml/rss2/

The problem is that only AbsoluteUri will be used for the redirect:

So for relative urls an System.InvalidOperationException will be thrown here:

url = response.Headers?.Location?.AbsoluteUri ?? url;

(https://github.com/arminreiter/FeedReader/blob/master/FeedReader/Helpers.cs#L67-L76)

A fix for this problem could be done like this (I am not entirely sure if that is the correct way to get the absolute url though):

if (response.Headers?.Location?.IsAbsoluteUri == true)
{
    url = response.Headers?.Location?.AbsoluteUri;
}
else
{
    var uri = new Uri(url);
    url = uri.GetLeftPart(UriPartial.Authority) + response.Headers?.Location;           
}

Thumbnail from feed

This is an example feed I parse:

<?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:xumo="http://www.xumo.com/rss/extensions/" xmlns:dcterms="http://purl.org/dc/terms/">
    <channel>
        <title><![CDATA[Sportword - Gold Cup (Highlights)]]></title>
        <description/>
        <item>
            <id><![CDATA[8102743]]></id>
            <projectid scheme="sdn:projectid"><![CDATA[9308]]></projectid>
            <title><![CDATA[Mexiko - Honduras (Highlight)]]></title>
            <description><![CDATA[Mexiko - Honduras (Highlight)]]></description>
            <keywords><![CDATA[Gold Cup,Highlights]]></keywords>
            <genre><![CDATA[Sport]]></genre>
            <program><![CDATA[26228]]></program>
            <guid isPermaLink="false"><![CDATA[74bd5f94-d3d4-4e2c-8ddf-adda35bde88f]]></guid>
            <sdnPlayoutId><![CDATA[74bd5f94-d3d4-4e2c-8ddf-adda35bde88f]]></sdnPlayoutId>
            <language><![CDATA[]]></language>
            <media:group>
                <media:title type="plain"><![CDATA[Mexiko - Honduras (Highlight)]]></media:title>
                <media:description type="plain"><![CDATA[Mexiko - Honduras (Highlight)]]></media:description>
                <media:keywords><![CDATA[Gold Cup,Highlights]]></media:keywords>
                                <media:content description="Player App" url="https://playout.3qsdn.com/74bd5f94-d3d4-4e2c-8ddf-adda35bde88f" type="application/x-shockwave-flash" duration="176.064" sdnformatid="player-app"/>
                <media:content description="MPEG DASH" url="https://sdn-global-streaming-cache.3qsdn.com/stream/9308/files/23/06/26/8102743/9308-xtmvcNwqYJ2DPyb.ism/manifest.mpd" type="application/dash+xml" duration="176.064" sdnformatid="mpeg-dash"/>
                <media:content description="HLS" url="https://sdn-global-streaming-cache.3qsdn.com/stream/9308/files/23/06/26/8102743/9308-xtmvcNwqYJ2DPyb.ism/playlist.m3u8" type="application/x-mpegURL" duration="176.064"  sdnformatid="hls"/>
                <media:content description="HDS"  url="https://sdn-global-streaming-cache.3qsdn.com/stream/9308/files/23/06/26/8102743/9308-xtmvcNwqYJ2DPyb.ism/manifest.f4m" type="text/xml" duration="176.064"  sdnformatid="hds"/>
                <media:content description="MP4 360p" url="https://sdn-global-prog-cache.3qsdn.com/9308/files/23/06/26/8102743/4-NkgzcWKQwTmb28Ph7Ln9.mp4" type="video/mp4" height="360" medium="video" fileSize="19710965" duration="176.064" sdnformatid="4" />
                <media:content description="MP4 720p" url="https://sdn-global-prog-cache.3qsdn.com/9308/files/23/06/26/8102743/2-bMvhpmxCdG3H27BfZYPq.mp4" type="video/mp4" height="720" medium="video" fileSize="64882999" duration="176.064" sdnformatid="2" />
                <media:content description="MP4 1080p" url="https://sdn-global-prog-cache.3qsdn.com/9308/files/23/06/26/8102743/1-3dwZmjRy4fQTYtrgzchM.mp4" type="video/mp4" height="1080" medium="video" fileSize="89496372" duration="176.064" sdnformatid="1" />
                <media:thumbnail url="https://sdn-global-prog-cache.3qsdn.com/9308/files/23/06/26/8102743/d3c7e504-7ed9-495d-9aed-0e5f7164444b.jpg"/>
            </media:group>
            <pubDate>Mon, 26 Jun 2023 02:45:01 UTC</pubDate>
        </item>
    </channel>
</rss>

Unfortunately my specificItem in the MediaGroup.Media items do not contain a thumbnail, just the videos. Am I missing out on something?
I use FeedReader.ReadFromString(feed) which worked flawlessly until now.

Thanks for any help in advance (:
R0boc0p

errror with SSL/TLS

Dear Team,

I got V 1.2.1 installed. Working fine with other RSS feeds.
When using this on this specific feed:
var feed = CodeHollow.FeedReader.FeedReader.Read("https://www.hkex.com.hk/Services/RSS-Feeds/News-Releases?sc_lang=en");

I get diverse error messages depending on which computer / Visual Studio version I use it from., ranging from something sort of SSL/TLS error (similar to this: https://stackoverflow.com/questions/41748946/paypal-api-httpwebrequest-throws-ssl-webexception) and for VS 2019 I get this message:
CodeHollow.FeedReader.Parser.FeedTypeNotSupportedException: 'unknown feed type html'

Any idea on how to fix this? Can you replicate?

Thanks
Mike

If I use below, it parses fine:
CodeHollow.FeedReader.Feed feed; var rssFeedContent = MakeRequest("https://www.hkex.com.hk/Services/RSS-Feeds/News-Releases?sc_lang=en"); if (!rssFeedContent.Contains("MakeRequest")) { feed = CodeHollow.FeedReader.FeedReader.ReadFromString(rssFeedContent); exchangeNewsCheckerHKEX.AnlyzeTheFeed(feed); }

with MakeRequest like this:
private static string MakeRequest(string url) { string result = "error in MakeRequest"; try {//https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 //| SecurityProtocolType.Ssl3 ; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) { Stream stream = resp.GetResponseStream(); StreamReader reader = new StreamReader(stream); result = reader.ReadToEnd(); resp.Close(); } } catch (Exception ex) { Logger.Error("Error in : MakeRequest:" + ex); } return result; }

.Net Core 2.1 Support and More Deadlocks

  • I want to add .netcore 2.1 support
  • I want to bump .netstandard from 1.3 to 2.0
  • I want to fix a couple more potential deadlocks
  • I want to make a ReadFromFileAsync

Automatic HTTP decompression should be enabled

The Adobe blog does currently not work since the HTTP content is received gzip encoded and FeedReader does not decode it:

Example:

https://theblog.adobe.com/news/feed

Error:

System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text)
   at CodeHollow.FeedReader.Parser.FeedParser.GetFeed(Byte[] feedContentData) in C:\Code\repos\FeedReader\FeedReader\Parser\FeedParser.cs:line 64
   at CodeHollow.FeedReader.FeedReader.ReadFromByteArray(Byte[] feedContent) in C:\Code\repos\FeedReader\FeedReader\FeedReader.cs:line 258
   at CodeHollow.FeedReader.FeedReader.<ReadAsync>d__10.MoveNext() in C:\Code\repos\FeedReader\FeedReader\FeedReader.cs:line 178

This fix is simple, I'll create a PR for it shortly.

How to find item thumbnail of Youtube Feed?

Hi @CodeHollow,

Could you tell me how to get the item thumbnail of Youtube Feed?
For example, if I read the Ted Talk from url feed https://pa.tedcdn.com/feeds/talks.rss, then I can get the thumbnail of each item using the following codes:

string feedUrl = "https://pa.tedcdn.com/feeds/talks.rss"; // This works.
// string feedUrl = "https://www.youtube.com/feeds/videos.xml?channel_id=UCAuUUnT6oDeKwE6v1NGQxug"; // This won't work.
var feed = await FeedReader.ReadAsync(feedUrl);
var xDocument = XDocument.Parse(feed.OriginalDocument);
var xNamespace = xDocument.Root.GetDefaultNamespace();

foreach(var item in feed.Items)
{
    var baseFeedItem = item.SpecificItem;
    string thumbnail = null;
    if (baseFeedItem.Element.Descendants().Any(x => x.Name.LocalName == xNamespace + "thumbnail"))
    {
        thumbnail = baseFeedItem.Element.Descendants().First(x => x.Name.LocalName == xNamespace + "thumbnail").Attribute("url").Value;
    }
    Console.WriteLine("thumbnail is: " + thumbnail);
}

But if I read Ted Talk feed from its Youtube channel https://www.youtube.com/feeds/videos.xml?channel_id=UCAuUUnT6oDeKwE6v1NGQxug, then I cannot get the thumbnail.

FeedReader.ReadAsync error with feeds with leading spaces.

FeedReader.ReadAsync method throw an error when the feed has leading spaces

Try it with FeedReader.ReadAsync("http://gurudeviaje.com/feed/");

Exception has occurred: CLR/System.AggregateException
An unhandled exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll: 'One or more errors occurred.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.Xml.XmlException : Unexpected XML declaration. The XML declaration must be the first node in the document, and no whitespace characters are allowed to appear before it. Line 2, position 3.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParsePI(StringBuilder piInDtdStringBuilder)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at CodeHollow.FeedReader.Parser.FeedParser.GetFeed(Byte[] feedContentData)
at CodeHollow.FeedReader.FeedReader.d__8.MoveNext()

Proxy Support

How deal with proxy ? I can't find anything in the documentation
I get some 443 issues using this.
Thanks.

Custom extension for specific tags

Hello,
Is it possible to add an extension similar to Syndication.cs myself? And if yes, how?
I need one for elements that start with "torznab:"
e.g.

<torznab:attr name="category" value="2010" />

And also one for non-default sub-elements of <item> like :
e.g.

<item>
      <size>4294967296</size>

Thanks!

System.Xml.XmlException: 'atom' is an undeclared prefix

Hello, @CodeHollow!

I'm experiencing XmlException when trying to read feed from: http://tjournal.ru/rss
Tested on .NETCore 2.0, NETStandard using CodeHollow.FeedReader 1.1.0.2
Debug output:

 "C:\Program Files\dotnet\dotnet.exe" C:/Users/User/RiderProjects/Tests/Tests/bin/Debug/netcoreapp2.0/Tests.dll
System.Xml.XmlException: 'atom' is an undeclared prefix. Line 116, position 6.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.LookupNamespace(NodeData node)
   at System.Xml.XmlTextReaderImpl.ElementNamespaceLookup()
   at System.Xml.XmlTextReaderImpl.ParseAttributes()
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at CodeHollow.FeedReader.Parser.FeedParser.GetFeed(String feedContent)
   at CodeHollow.FeedReader.FeedReader.<ReadAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Tests.Program.<MainAsync>d__1.MoveNext() in C:\Users\User\RiderProjects\Tests\Tests\Program.cs:line 18

Sample code to reproduce the issue:

static async void MainAsync() {
    try {
        var feed = await FeedReader.ReadAsync("http://tjournal.ru/rss");
        Console.Write(feed);
    } catch (Exception e) {
        Console.WriteLine(e);
    }
}

Thanks in advance!

FeedItem.Link returns incorrect link for AtomItems with multiple links

FeedItem.Link can return the incorrect link for Atom feeds where multiple link elements exist for an <entry>.

In the Atom feed below, each <entry> contains multiple <link> tags each points at different things such as a feed for comments on the news item, the next news item, etc. It looks like this:

<link rel="replies" type="application/atom+xml" href="https://www.columbiaspy.com/feeds/2173405820987631614/comments/default" title="Post Comments"/>
<link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=8146091995480420252&amp;postID=2173405820987631614&amp;isPopup=true" title="0 Comments"/>
<link rel="edit" type="application/atom+xml" href="https://www.blogger.com/feeds/8146091995480420252/posts/default/2173405820987631614"/>
<link rel="self" type="application/atom+xml" href="https://www.blogger.com/feeds/8146091995480420252/posts/default/2173405820987631614"/>
<link rel="alternate" type="text/html" href="https://www.columbiaspy.com/2022/07/driving-for-drama-benefit-car-show.html" title="DRIVING FOR DRAMA BENEFIT CAR SHOW"/>

FeedItem.Link is set by the BaseFeedItem, which simply grabs the first <link> tag and uses that, which is incorrect. The <link rel="alternate" type="text/html"> tag should be used instead.

atom.xml.txt

I am happy to submit a fix, but it would involve a slight design change. I suggest that BaseFeedItem use abstract properties for Title and Link. That way the individual classes like AtomFeedItem or Rss10FeedItem can implement their own logic to return the appropriate value for those. In this case, AtomFeedItem would use Linq to find the appropriate <link rel="alternate" type="text/html"> link tag.

Can't read some rss feeds

Hello, @CodeHollow!

While developing a mobile application using FeedReader library I have encountered an issue when processing some RSS feeds. Debug output says:

Exception thrown: 'System.Xml.XmlException' in System.Private.CoreLib.ni.dll

It happens when I try to process any of these feeds:

https://habrahabr.ru/rss/interesting/
https://geektimes.ru/rss/
https://vc.ru/feed

I've noticed that each item in these feeds does not have content xml element. I'll try to investigate and provide more detailed information on this issue soon.

Thanks a lot for your library!

DownloadAsync - InvalidOperationException - same request retry

public static async Task<string> DownloadAsync(string url)
        {
            url = System.Net.WebUtility.UrlDecode(url);

            using (var request = new HttpRequestMessage(HttpMethod.Get, url))
            {
                request.Headers.TryAddWithoutValidation(ACCEPT_HEADER_NAME, ACCEPT_HEADER_VALUE);
                request.Headers.TryAddWithoutValidation(USER_AGENT_NAME, USER_AGENT_VALUE);

                var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);

                if (!response.IsSuccessStatusCode)
                {
                    request.Headers.Clear();
                    response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);
                }

                return Encoding.UTF8.GetString(await response.Content.ReadAsByteArrayAsync());
            }
        }

should be:

public static async Task<string> DownloadAsync(string url)
        {
            url = System.Net.WebUtility.UrlDecode(url);
            HttpResponseMessage response;
            using (var request = new HttpRequestMessage(HttpMethod.Get, url))
            {
                request.Headers.TryAddWithoutValidation(ACCEPT_HEADER_NAME, ACCEPT_HEADER_VALUE);
                request.Headers.TryAddWithoutValidation(USER_AGENT_NAME, USER_AGENT_VALUE);

                response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);
            }
            if (!response.IsSuccessStatusCode)
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, url))
                {
                    response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);
                }
            }

            return Encoding.UTF8.GetString(await response.Content.ReadAsByteArrayAsync());
        }

Expose Extensions

Is it possible to expose the Extensions class out so when accessing XElement we have the same methods available as are used when parsing feeds as otherwise Element is just a plain XElement without these nice methods.

Maybe my C# knowhow is limited and this is already possible, but currently ive just copied Extensions.cs into my project.

Problem with charset

When I read RSS https://www.e1.ru/talk/forum/rss.php?f=86 I had problems with charset.

But in response from server I have header with information about charset: content-type: text/xml;charset=WINDOWS-1251. How I can set some parameter, that FeedReader use this header?

image

HTTP 302 handling

I have a number of RSS feeds responding with an HTTP 302 requiring a redirect, which I was able to resolve by cloning the repo and altered this line of code in FeedReader/Helpers.cs - line 59.

if (autoRedirect && (statusCode == 301 || statusCode == 302|| statusCode == 308)) 

Should I submit a pull request for this change?

Bad usage of the HttpClient

Your implementation of the usage from the HttpClient is bad.

Unfortunately, correct lifetime management of HttpClient is one of the biggest gotchas in .NET, MS really needs to fix it: it's unreasonable to expect people to understand concepts like socket-exhaustion and such when all they want to do is make a web-request every 15 minutes in a Windows Service, for example.

So a better solution is using a IHttpClientFactory to create the HttpClient for each single request. Maybe you can realize this with HttpClientFactory.CreateHttpClient.

This would be a better solution, but there are still a lot of issues with it:

  1. There is no way for me to set a UserClient (ApplicationName) for the HttpClient.
  2. There is no way for me to configure a Proxy server.
  3. There is no way for me to log HTTP requests.

To let me do all of this, it would be nice if you would implement a Callback function, how I can create the HttpClient by myself.

You could realize this, for example, with a static event in your Helpers.cs file. If you invoke this event before each HttpClient usage, I could create my own HttpClient every time fresh. And if I don't register to the event, you could use your static HttpClient furthermore.

This solution should be not a lot of work for you.

If you are interested, I would realize this and offer with a Pull Request to you.

What do you thing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.