Both wget and curl can download files, however I would like to name the file based on its Content-Type header. For example

video/x-flv

Should be saved with .flv extension. With wget and curl by default files are only saved with proper extension if the URL provides one. How could I go about saving files with proper extension regardless of the URL?