示例#1
0
        public void Initialize()
        {
            _httpWebRequestFactory = new HttpWebRequestFactory();
            _streamReaderFactory = new StreamReaderFactory();
            _httpWebProcessor = new HttpWebProcessor(_streamReaderFactory);
            _httpWebProxyRequestFactory = new HttpWebProxyRequestFactory(_httpWebRequestFactory, _httpWebProcessor);
            _httpWebResponseFactory = new HttpWebResponseFactory();
            _httpWebProxy = new HttpWebProxy(_httpWebProxyRequestFactory, _httpWebResponseFactory, _httpWebProcessor);

            _httpWebRequestParametersGet = new HttpWebRequestParameters()
            {
                RequestUri = new Uri("http://httpbin.org/get"),
                ContentType = "*/*",
                Method = HttpMethod.Get,
                ReadWriteTimeout = 30000,
                Timeout = 30000,
                ResponseCallback = ResponseCallbackGet
            };

            var encoding = new ASCIIEncoding();
            _httpWebRequestParametersPost = new HttpWebRequestParameters()
            {
                RequestUri = new Uri("http://httpbin.org/post"),
                RequestData = POST_DATA_TEST,
                Encoding = encoding,
                ContentLength = POST_DATA_TEST.Length,
                ContentType = "*/*",
                Method = HttpMethod.Post,
                ReadWriteTimeout = 30000,
                Timeout = 30000,
                ResponseCallback = ResponseCallbackPost
            };

            _manualResetEventGet = new ManualResetEvent(false);
            _manualResetEventPost = new ManualResetEvent(false);
        }
示例#2
0
 public HttpWebProxy(IHttpWebProxyRequestFactory httpWebProxyRequestFactory, IHttpWebResponseFactory httpWebResponseFactory, IHttpWebProcessor httpWebProcessor)
 {
     _httpWebProxyRequestFactory = httpWebProxyRequestFactory;
     _httpWebResponseFactory = httpWebResponseFactory;
     _httpWebProcessor = httpWebProcessor;
 }