HttpWebRequest - DNS Resolution in advance

2019-08-12 02:50发布

Using the HttpWebRequest (even when calling the async get method), it can take up to 15 seconds due to DNS resolution:

A Domain Name System (DNS) query may take up to 15 seconds to return or time out.

Is it possible to make this query in advance, so that it wont spend time at it when making the request?

1条回答
地球回转人心会变
2楼-- · 2019-08-12 03:17

It is very likely that the DNS resolution in HttpWebRequest is not pluggable. But you can do the resolution yourself and rewrite the URLs to use the resolved IP as the host name. Make sure to set the correct host-header, though, because many websites require it. Also, I believe HTTPS will be harder because certificate validation is based in part on the host name.

查看更多
登录 后发表回答