Is this normal? there is no file like that. But i recieve 1. Whatever i write there as file name... such as http://armasoft.net/... i always get result positive... How can i get normal result? I need true or false?
InitNetwork()
a=ReceiveHTTPFile("http://armasoft.net/xxx","/home/arma/TEST")
Debug a
ReceiveHTTPFile
Re: ReceiveHTTPFile
If there is no file .... you get the server error page, like 404-Page....
So a #True result is normal, ReceiveHTTPFile download something.
So a #True result is normal, ReceiveHTTPFile download something.
Re: ReceiveHTTPFile
Then what is the result meaning?
There is an help on document...
Example
InitNetwork()
Filename$ = SaveFileRequester("Where to save index.php ?", "", "", 0)
If ReceiveHTTPFile("http://www.purebasic.com/index.php", Filename$)
Debug "Success"
Else
Debug "Failed"
EndIf
It says always Success... Never says Failed... What a strange
There is an help on document...
Example
InitNetwork()
Filename$ = SaveFileRequester("Where to save index.php ?", "", "", 0)
If ReceiveHTTPFile("http://www.purebasic.com/index.php", Filename$)
Debug "Success"
Else
Debug "Failed"
EndIf
It says always Success... Never says Failed... What a strange
Re: ReceiveHTTPFile
Because it is download this page, that comes with this url....
on your first try it downloads the error page, so 1 is ok.
0 is the result, if nothing is downloaded to your computer!
on your first try it downloads the error page, so 1 is ok.
0 is the result, if nothing is downloaded to your computer!
Re: ReceiveHTTPFile
For me this is nothing useful... Some thing like bug... How can i detect if successfully download or not... and Why?
I solve my situation but this command works as stupid. I use wget now... It says error if there is no file to download. So i solve my problem. But in my oppinion this is wrong. If it will always says True... When will it say False? And what is it for?
I solve my situation but this command works as stupid. I use wget now... It says error if there is no file to download. So i solve my problem. But in my oppinion this is wrong. If it will always says True... When will it say False? And what is it for?
Re: ReceiveHTTPFile
You have to do a HTTPRequest first and check the HTTP status code.
Here an untested code:
Maybe the helps to think about the problem ...
Here an untested code:
Code: Select all
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
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
PB Last Final / Last Beta Testing