HttpWebRequest's Timeout and ReadWriteTimeout — What do these mean for the underlying TCP connection?

前端 未结 4 1032
醉酒成梦
醉酒成梦 2021-02-03 22:19

I believe I understand the practical differences between HttpWebRequest.Timeout and HttpWebRequest.ReadWriteTimeout. However, I\'m seeking further<

4条回答
  •  一向
    一向 (楼主)
    2021-02-03 23:20

    The previous answers suggest changing the ReadWriteTimeout and the timeout. Here's the Webclient override function you need to do this.

            protected override WebRequest GetWebRequest(Uri address)
            {
                _request = base.GetWebRequest(address);
    
                var httpRequest = _request as HttpWebRequest;
                httpRequest.ReadWriteTimeout = 600000;
                httpRequest.Timeout = 600000;
                httpRequest.ContinueTimeout = 600000;
                if (_request != null)
                {
                    httpRequest.AllowAutoRedirect = AutoRedirect;
                    httpRequest.CookieContainer = CookieContainer;
                    httpRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
    
                    Setup?.Invoke(httpRequest);
                }
    
                return _request;
            }
    

提交回复
热议问题