private static GetHeadResponse HandleWebException(string header, WebException we)
{
using (var errorResponse = we.Response as HttpWebResponse)
{
// The Error Response is null which is indicative of either
// a bad request or some other problem
if (errorResponse == null)
{
return new GetHeadResponse();
}
else
{
return new GetHeadResponse
{
HeaderValue = errorResponse.Headers[header],
StatusCode = errorResponse.StatusCode
};
}
}
}