ResponseExtensions
Represents some useful extensions for the response.
using AngleSharp.Network;
namespace AngleSharp.Extensions
{
public static class ResponseExtensions
{
public static MimeType GetContentType(this IResponse response)
{
string path = response.Address.Path;
int num = path.LastIndexOf('.');
string extension = (num >= 0) ? path.Substring(num) : ".a";
string defaultType = MimeTypeNames.FromExtension(extension);
return response.GetContentType(defaultType);
}
public static MimeType GetContentType(this IResponse response, string defaultType)
{
return new MimeType(response.Headers.GetOrDefault(HeaderNames.ContentType, defaultType));
}
}
}