feeds icon indicating copy to clipboard operation
feeds copied to clipboard

[bug] Sending deprecated Content-Type header

Open geira opened this issue 2 years ago • 3 comments

Describe the bug

Currenly Gorilla outputs the Content-Type header as "application/xml". According to the RSS Standard Board, the correct Content-Type should be "application/rss+xml".

Versions

go version go1.17.5 linux/amd64 github.com/gorilla/feeds v1.1.1

Steps to Reproduce

$ curl -s -D - -o /dev/null http://localhost:8000/rss
HTTP/1.1 200 OK
Content-Type: application/xml
Date: Fri, 18 Mar 2022 13:51:01 GMT
Transfer-Encoding: chunked

Expected behavior

$ curl -s -D - -o /dev/null http://localhost:8000/rss
HTTP/1.1 200 OK
Content-Type: application/rss+xml
Date: Fri, 18 Mar 2022 13:51:01 GMT
Transfer-Encoding: chunked

geira avatar Mar 18 '22 13:03 geira

"application/xml" seems to work fine. Not sure how well "application/rss+xml" is supported, I checked in chrome and it is not being formatted properly when served as "application/rss+xml".

RSS feeds should be served as application/rss+xml (RSS 1.0 is an RDF format, so it may be served as application/rdf+xml instead). Atom feeds should use application/atom+xml. Alternatively, for compatibility with widely-deployed web browsers, any of these feeds can use one of the more general XML types - preferably application/xml.

source

meblum avatar Sep 21 '23 17:09 meblum

"Seems to work fine" is not a good reason to violate an official standard. Also, define "work". RSS feeds are designed to be read by RSS readers. They are not meant to be consumed by end users as nicely formatted XML (even though that can sometimes be useful for developing).

Earlier most browsers had built-in RSS readers, but these days practically all of them have removed that functionality in favour of browser plugins or separate programs. Now, the only way to tell the browser to open the feed in said piece of software is to use a dedicated content-type, otherwise the output will be hijacked by the browser and shown as XML (or handed to a dedicated XML formatter plugin).

So it all depends on who your target audience are. Do you want to format XML for the benefit of developers, use application/xml. Or do you want people to read the news articles they have subscribed to, use application/rss+xml. Want to support both? Let the user decide for themself which kind of output they want:

  • https://api.met.no/weatherapi/metalerts/1.1/test.rss
  • https://api.met.no/weatherapi/metalerts/1.1/test.xml

geira avatar Sep 21 '23 19:09 geira

The extensions shared above do properly handle content type application/xml, but anyhow, I don't think this issue is gorilla/feeds related, this module is not the one handling the HTTP serving of the feeds, and is definitely not the one setting the HTTP headers.

How are how you serving the feed? You should be able to set the desired Content-Type when returning the response.

meblum avatar Sep 22 '23 00:09 meblum