Content type detection

Here is another annoying and common programming-related problem: content type detection. The commonly applied solutions are:

Of course there are related controversies and implementation inconsistencies, and one has to decide what to apply on case-by-case basis.

It could have been mostly solved if each chunk of shared data had a MIME type associated with it right from the moment of authoring, maybe via a single-line header only containing that type, yet apparently it's not realistic at all, judging by adoption and support of all the other standards. Would surely be controversial, too.

As usual, one can try to set a system like that locally (for oneself), what would take some time and effort, without much of benefit. But in general, reliably picking software for data/file processing (including viewing or editing by a user) is an unsolved problem, which is not likely to get solved in the observable future, and which is particularly annoying because it can be so simple. Though it's not alone in that.