Exemplo n.º 1
0
 private void ProcessReponse(HttpWebResponseBase httpWebResponse, HttpWebProxyRequest httpWebProxyRequest)
 {
     string responseData = null;
     Stream responseStream = null;
     try
     {
         responseStream = httpWebResponse.GetResponseStream();
         responseData = httpWebProxyRequest.ProcessResponseStream(responseStream);
     }
     finally
     {
         if (responseStream != null)
         {
             responseStream.Close();
         }
         if (httpWebResponse != null)
         {
             httpWebResponse.Close();
         }
     }
     if (httpWebProxyRequest.ResponseCallback != null)
     {
         httpWebProxyRequest.ResponseCallback(responseData);
     }
 }
Exemplo n.º 2
0
 private void ProcessAsyncRequest(HttpWebProxyRequest httpWebProxyRequest, IAsyncResult asyncResult)
 {
     Stream requestStream = null;
     try
     {
         requestStream = httpWebProxyRequest.HttpWebRequestBase.EndGetRequestStream(asyncResult);
         httpWebProxyRequest.ProcessRequestStream(httpWebProxyRequest.RequestBytes, requestStream);
     }
     finally
     {
         if (requestStream != null)
         {
             requestStream.Close();
         }
     }
     httpWebProxyRequest.HttpWebRequestBase.BeginGetResponse(new AsyncCallback(GetResponseCallback), httpWebProxyRequest);
 }
        public HttpWebProxyRequest Create(HttpWebRequestParameters httpWebRequestParameters)
        {
            byte[] requestBytes = httpWebRequestParameters.RequestBytes;
            if (requestBytes == null && !string.IsNullOrEmpty(httpWebRequestParameters.RequestData))
            {
                requestBytes = _httpWebProcessor.GetRequestBytesFromRequestData(httpWebRequestParameters.RequestData, httpWebRequestParameters.Encoding);
            }
            var httpWebProxyRequest = new HttpWebProxyRequest()
            {
                Method = httpWebRequestParameters.Method,
                RequestBytes = requestBytes,
                ProcessRequestStream = httpWebRequestParameters.ProcessRequestStream,
                ProcessResponseStream = httpWebRequestParameters.ProcessResponseStream,
                ResponseCallback = httpWebRequestParameters.ResponseCallback
            };

            var httpWebRequest = _httpWebRequestFactory.Create(httpWebRequestParameters.RequestUri);
            Setup(httpWebRequestParameters, httpWebRequest);
            httpWebProxyRequest.HttpWebRequestBase = httpWebRequest;

            return httpWebProxyRequest;
        }
Exemplo n.º 4
0
 private void SetupDelegates(HttpWebProxyRequest httpWebProxyRequest)
 {
     if (httpWebProxyRequest.ProcessRequestStream == null)
     {
         httpWebProxyRequest.ProcessRequestStream = ProcessRequestStream;
     }
     if (httpWebProxyRequest.ProcessResponseStream == null)
     {
         httpWebProxyRequest.ProcessResponseStream = ProcessResponseStream;
     }
 }
Exemplo n.º 5
0
 private void ProcessRequest(HttpWebProxyRequest httpWebProxyRequest)
 {
     Stream requestStream = null;
     try
     {
         requestStream = httpWebProxyRequest.HttpWebRequestBase.GetRequestStream();
         httpWebProxyRequest.ProcessRequestStream(httpWebProxyRequest.RequestBytes, requestStream);
     }
     finally
     {
         if (requestStream != null)
         {
             requestStream.Close();
         }
     }
 }