viewpoint-particle

Author Topic: HTTPOpen does not return 404, Page Not Found  (Read 1635 times)

dmsimmonds

  • Newbie
  • *
  • Posts: 3
HTTPOpen does not return 404, Page Not Found
« on: June 10, 2014, 11:17:24 am »
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.
   tophandle=iBegin(0,"","")
   connecthandle=iHostConnect(tophandle, ThisHost,@HTTP,"", "")
   datahandle=iHttpInit(connecthandle, "GET", Object, "",0)
   If datahandle==0
      err=iGetLastError()
      Message("Last Error",err)
      iClose(tophandle)
      Exit
   EndIf
   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()
      Else
         errstr = "HTTP Error"
      EndIf
      Message(errstr,rslt)
      iClose(tophandle)
      Exit
   EndIf
   xx=iReadData(datahandle, StrCat(ProgramPath, "HTTPGet.txt"))
   iClose(datahandle)
   iClose(connecthandle)
   iClose(tophandle)
   Message("All","Done")
Exit

Is there a better way to do this?

JTaylor

  • Pundit
  • *****
  • Posts: 731
    • Data & Stuff Inc.
Re: HTTPOpen does not return 404, Page Not Found
« Reply #1 on: June 10, 2014, 11:34:53 am »
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?

Jim

dmsimmonds

  • Newbie
  • *
  • Posts: 3
Re: HTTPOpen does not return 404, Page Not Found
« Reply #2 on: June 10, 2014, 11:52:59 am »
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.

Deana

  • Wilson WindowWare Tech Support
  • Tech Support
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: HTTPOpen does not return 404, Page Not Found
« Reply #3 on: June 10, 2014, 02:48:55 pm »
Cross posted topic. Please only post questions to one board. See my response to this topic here: http://forum.winbatch.com/index.php?topic=967.msg4270.

Deana F.
Technical Support
Wilson WindowWare Inc.