简体   繁体   中英

HttpWebResponse timeout

I am getting timeout exception on code bellow. Only this site is problematic. What is the problem?

string ackoURL = "https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ackoURL);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
  //this code is never executed
}

I tried modifying SecurityProtocol, KeepAlive and simmilar things. Without success.

it waiting these headers

在此输入图像描述

..and it worked

Uri u = new Uri("https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu");
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(u);
        request.AutomaticDecompression = DecompressionMethods.GZip;
        request.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            using(Stream stream = response.GetResponseStream())
            {
                using(StreamReader reader= new StreamReader(stream))
                {
                    var result = reader.ReadToEnd();

                }
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM