Was trying to replace the custom task that I wrote with this but this lacks some features.
So if useSourceFileName == true, try get the sourceFileName from the Content-Disposition header. Something like this:
HttpResponseMessage response = await RequestGetAsync(input);
HttpContentHeaders headers = response.Content.Headers;
if (String.IsNullOrEmpty(fileName) && headers.ContentDisposition != null)
{
fileName = headers.ContentDisposition.FileName.Trim('"');
}
if (String.IsNullOrEmpty(fileName))
{
throw new Exception("Filename is empty! HTTP-Response headers: \n"+ headers.ToString());
}
And FileExistsAction: Throw Exception|Overwrite|Rename would be nice addition too.