I want to learn content-type of a file. what should I do?

In my code I want to do:

I give an url to download.
the function learns the content-type and
if it is a text file downloads it.
else will raise an error.

	[[alternative HTML version deleted]]

