public HttpWebResponseBasedResponse(HttpWebRequestBasedRequest request, HttpWebRequest nativeRequest) { _request = request; try { _response = (HttpWebResponse)nativeRequest.GetResponse(); } catch (WebException e) { _response = (HttpWebResponse)e.Response; } if (_response != null) { Status = new HttpStatus((int)_response.StatusCode, _response.StatusDescription); RaiseStatusChanged("Connected."); if (_response.ContentLength > 0) { _entity = new HttpEntity(new ProgressStream(_response.ContentLength, RaiseProgress, _response.GetResponseStream())); } } else { Status = new HttpStatus(-1, "No response"); RaiseStatusChanged("No response."); } }
public HttpWebResponseBasedResponse(HttpWebRequestBasedRequest request, HttpWebRequest nativeRequest, Action<TransferProgress> notifyProgress) { _request = request; try { _response = (HttpWebResponse)nativeRequest.GetResponse(); } catch (WebException e) { _response = (HttpWebResponse)e.Response; } if (_response != null) { Status = new HttpStatus((int)_response.StatusCode, _response.StatusDescription); RaiseStatusChanged("Connected."); if (_response.ContentLength == -1 || _response.ContentLength > 0) { _entity = new HttpEntity(new ProgressStream(_response.ContentLength, notifyProgress, _response.GetResponseStream())); } } else { Status = new HttpStatus(-1, "No response"); RaiseStatusChanged("No response."); } }