Android Question Jetty client setting Content-Range value properly not working

OMS

Member
Hi,
My previous file server was a Windows IIS and I could download a larg file on my b4a app easily.
if download would fail meanwhile I could resume download using
B4X:
Dim request As OkHttpRequest
request.InitializeGet(myURL & "/" & myFilename & "?dumyParam="  & Rnd(10000,1999999999) & Rnd(10000,1999999999)) ' dumyParam helps avoid browser cach
If PreviouslyDownloadedsize > 0 And  PreviouslyDownloadedsize < TotalBytes Then
            request.SetHeader("Range","bytes=" & PreviouslyDownloadedsize & "-")
End If
HC.Execute(request, 4)
But I now I am using a B4J server.
It seems that Jetty does not support partial download as easy as IIS web server.
there are some links that explain this:

Example 7 on this page:

please any body help how to implement it in B4A

Thanks
 

OMS

Member
since I am using a CountingOutputStream as Target of Response.GetAsynchronously("Response", Target, True, TaskId)
so in stead of httputils2, I prefered to make my custome httputil which borrows mosty from httputils2
 
Upvote 0

OMS

Member
Using HttpClient directly is never correct. Use the source code of OkHttpUtils2 and modify it as needed.

This is actually a B4J question. You can set acceptRanges to true with:
B4X:
srvr.SetStaticFilesOptions(CreateMap("acceptRanges": True))
Thank you very much. This solved the problem.
 
Upvote 0
Top