Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: iHttpOpen Not Returning 404 200
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") ExitWhen I intentionally mis-spell the URL, I still get a 200. and when I use iReadData, I get the following returned: <script src='Login.jsgz'></script>
Is there a better way to do this?
Here is a code sample, that I put together that does return 404 from a server that actually returns a 404 error:
;Load the Appropriate Extender AddExtender("WWINT44I.DLL",0,"WWINT64I.DLL") host = "www.barrons.com" url = "/bie/articles/current/toc.htm" tophandle=iBegin( 0, "", "" ) If tophandle==0 err=iGetLastError( ) Message( "iBegin Last Error", err ) GoSub CLEANUP Exit EndIf connecthandle = iHostConnect( tophandle, host, @HTTP, "", "" ) err = iGetLastError( ) If connecthandle == 0 err = iGetLastError( ) Message( "iHostConnect Last Error", err ) GoSub CLEANUP Exit EndIf datahandle = iHttpInit( connecthandle, "GET", url, "", 4 );Enable Keep Alive If datahandle == 0 err = iGetLastError( ) Message( "iHttpInit Last Error", err ) GoSub CLEANUP Exit EndIf rslt=iHttpOpen(datahandle, "" , 0, 0) Pause('iHttpOpen',rslt) Exit :CLEANUP If IsDefined( datahandle ) Then iClose( datahandle ) If IsDefined( connecthandle ) Then iClose( connecthandle ) If IsDefined( tophandle ) Then iClose( tophandle ) ReturnApparently you can use "Fetch as Google" (or other tools available on the web) to verify whether the URL is actually returning the correct code. Reference: https://support.google.com/webmasters/answer/181708?hl=en
Article ID: W18504
Filename: iHTTPOpen Not Returning 404.txt
File Created: 2014:06:10:14:12:50
Last Updated: 2014:06:10:14:12:50