Archived Boards > WinBatch Script Exchange

HTTPOpen does not return 404, Page Not Found


I'm writting a monitor program to see if our web server is ready to accept request by trying to resolve a URL of a known page. If the page is not found, then my program would send messages. Trying to use HTTPOpen() and never receive the 404 that I expected. Here is the test script.
   connecthandle=iHostConnect(tophandle, ThisHost,@HTTP,"", "")
   datahandle=iHttpInit(connecthandle, "GET", Object, "",0)
   If datahandle==0
      Message("Last Error",err)
   myheader=StrCat("user_process: My cool app", @CRLF, "app_version: 12.0")
   rslt=iHttpOpen(datahandle, "" , 0, 0)
   Message("HTTPGet", "Response Code = %rslt%")
   If rslt=="ERROR" || rslt!=200
      If rslt == "ERROR"
         errstr = "WinInet Error"
         rslt = iGetLastError()
         errstr = "HTTP Error"
   xx=iReadData(datahandle, StrCat(ProgramPath, "HTTPGet.txt"))

Is there a better way to do this?

Not sure if this applies in your situation but if your webserver has a custom error page defined you will not get a 404 because it redirects to the custom page so, in practical terms, it never has a page that doesn't exist.  Hope this makes sense.

The other question is, what do you get as a response to HTTPOpen?


There is no custome error page, in fact, if i use a browser with the same URL I dod get the 404, Page Not Found. The data I get usinf the iReadData() is
<script src='Login.jsgz'></script>

I get a 200 Response code.

Cross posted topic. Please only post questions to one board. See my response to this topic here:


[0] Message Index

Go to full version