5
GetResponse 호출에서 WebException을 처리하고 WebException Response에서 응답을 추출하는 방법에 대한 예를 발견했습니다. 두 번째 퍼즐은 null 응답이 throw로 처리되는 이유입니다. 어떠한 제안?GetResponse가 WebException을 throw하고 ex.Response가 null입니다.
HttpWebResponse response = null;
try
{
response = (HttpWebResponse) request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
if (null == response)
{
throw;
}
}