You have to do a HTTPRequest first and check the HTTP status code.
Here an untested code:
Code:
Procedure ReceiveHTTPFileX(URL.s, Filename.s, Flags=#PB_Ignore, UserAgent.s=#Empty$)
Protected httpReq, httpStatus
httpReq = HTTPRequest(#PB_HTTP_Get, URL, #Null$, #PB_HTTP_HeadersOnly)
If httpReq
httpStatus = Val(HTTPInfo(httpReq, #PB_HTTP_StatusCode))
FinishHTTP(httpReq)
If httpStatus = 200
If UserAgent <> #Empty$
ProcedureReturn ReceiveHTTPFile(URL, Filename, Flags, UserAgent)
ElseIf Flags <> #PB_Ignore
ProcedureReturn ReceiveHTTPFile(URL, Filename, Flags)
Else
ProcedureReturn ReceiveHTTPFile(URL, Filename)
EndIf
Else
; HTTP request failed
ProcedureReturn #Null
EndIf
Else
; Http request failed
ProcedureReturn #Null
EndIf
EndProcedure
Maybe the helps to think about the problem ...