Hacker News new | ask | show | jobs
by mort96 1419 days ago
Browsers send "Accept: text/html" explicitly. For my pastebin[1], I send an HTML document when "text/html" is in the list of accepted formats, and I just send the plain data otherwise. This seems to work in practice, doesn't hard-code knowledge about curl, and doesn't require curl users to add custom headers.

[1]: https://sr.ht/~mort/coffeepaste/

2 comments

I feel that neatly meets the kind of thing these params are for - if you ask a server for content and say "Accept: */*" the server should be free to return that content in whatever format it likes.
That format should probably be the original file then, the one that was uploaded/pasted.
Why do you feel that way?
That's literally what the header means according to the rfc.
plus regardless of the official meaning, how _else_ would you interpret a header that's saying "I'll accept anything". Like the only reasonable response is "cool, here's what i felt like giving you since you gave me no guidance whatsoever and said you could handle anything"
Yup, I do the same with dotfilehub.com

E.G,

curl https://dotfilehub.com/knoebber/emacs

results in plain text