简体   繁体   中英

Extracting StatusCode from TWebBrowser OnNavigateError in Delphi 10.3

I'm trying to get the HTTP response code in an OnNavigateError event of a TWebBrowser. The StatusCode passed to me is always -2146697211 when it should be 404. What am I missing? I'm using Delphi 10.3.

Why is this a separate error code and not a HTTP one? Because it happens before HTTP is performed: looking up the IP address to a hostname has failed - nobody knows which IP address the hostname you tried to browse to has. That's what the Domain Name System (DNS) is for. Not being able to get in contact with a server is a different thing than being able and getting a response. HTTP 404 is a reponse. But since you don't even got a response, hence you cannot get a HTTP status code.


Long story short: host not found (instead of "HTTP 404" = host found, but not the page you're looking for ). Try it with an address/a hostname that can be actually resolved.

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