When I try to download a file form my websever with the following code, job.Success is always true, even the filter blocks the request with wrong login-data. Why is the behavior like this? My problem is, that the file in the jobDone-event is written without getting data from the server before and the file will be corrupted. Is it possible to return the success of the job as false?
Client-Code:
Server-Code.
Thanks for help...
Client-Code:
B4X:
Sub K_laden
Dim K As HttpJob
K.Initialize("K", Me)
K.Download2(ServerPfad & "/Test/test.txt", Array As String("absender", Absender, "passwort", PasswortServer))
End Sub
Sub JobDone (Job As HttpJob)
Select Job.JobName
Case "K"
If Job.Success=True Then
Dim out As OutputStream
out=File.OpenOutput(File.DirApp, "Test/test.txt", False)
File.Copy2(Job.GetInputStream, out)
out.Close
Else
Log("Error loading file!")
End If
End Select
End Sub
Server-Code.
B4X:
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
Dim In As InputStream = req.InputStream
Dim absender As String = req.GetParameter("absender")
Dim passwort As String = req.GetParameter("passwort")
Dim Ergebnis As String
Ergebnis = NutzerDB.CheckCredentials(absender, passwort)
If Ergebnis <> "Zugriff gewaehrt!" Then
If Ergebnis.Length=0 Then
Ergebnis="Unautorisierter Zugriff!"
End If
resp.Write(Ergebnis)
Return False
Else
Return True
End If
End Sub
Thanks for help...