Пример #1
0
 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.");
     }
 }
Пример #3
0
        public WebRequestHttpClient()
        {
            _requestCreator = (uri, proxy) =>
            {
                var request = new HttpWebRequestBasedRequest(uri, proxy)
                {

                };
                Notifier.RaiseNewRequest(request);
                return request;
            };
            Notifier = HttpNotifier.Default;
        }
 public HttpWebResponseBasedResponse(HttpWebRequestBasedRequest request, HttpWebRequest nativeRequest)
 {
     _request = request;
     try
     {
         _response = (HttpWebResponse)nativeRequest.GetResponse();
     }
     catch (WebException e)
     {
         _response = (HttpWebResponse)e.Response;
     }
     RaiseStatusChanged("Connected.");
     if (_response.ContentLength > 0)
     {
         _entity = new HttpEntity(new ProgressStream(_response.ContentLength, RaiseProgress, _response.GetResponseStream()));
     }
 }