Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Sending deprecated Content-Type header #93

Open
geira opened this issue Mar 18, 2022 · 3 comments
Open

[bug] Sending deprecated Content-Type header #93

geira opened this issue Mar 18, 2022 · 3 comments
Labels

Comments

@geira
Copy link

geira commented Mar 18, 2022

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
@meblum
Copy link
Contributor

meblum commented Sep 21, 2023

"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

@geira
Copy link
Author

geira commented Sep 21, 2023

"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:

@meblum
Copy link
Contributor

meblum commented Sep 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants