Android Question source exhausted prematurely using OkHttp

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi,
Using V7 OkHttp v 1.20 and OkHttpUtils2 v2.5
Im gettin this error:

!!! java.io.EOFException: source exhausted prematurely

trying to get a web page that is getted ok by any browser.

just try:

http://calc.futurobursatil.com.ar/xmloc?F=Sxml&S=&Z=1&ES=DICA,AUSO,CAPU,IRSA

This is an extract of mu code:
B4X:
    Dim HttpJob1 As HttpJob

        Try
          HttpJob1.download(URL)
            HttpJob1.GetRequest.Timeout=5000
        Catch
            Log(">> Error en lectura web")
            Jobeando=False
            Return

Sub JobDone(Job As HttpJob)
    If Job.Success = True Then   
        Dim s As String
        s = Job.GetString
        Try
            ParsearHtmlFB(s)
        Catch
            Log("BLABLABLA ")
        End Try
    Else   
        Log("!!! serv - ERROR READING WEB PAGE !!!! ")  'here is the error shown
        Log("!!! "&Job.ErrorMessage)
    End If
End Sub

How can I solve this?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The server returns incorrect content length.

You can workaround it by disabling compression:
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.Download("http://calc.futurobursatil.com.ar/xmloc?F=Sxml&S=&Z=1&ES=DICA,AUSO,CAPU,IRSA")
j.GetRequest.SetHeader("Accept-Encoding", "identity") 'add a reference to OkHttp library
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
   Log(j.GetString)
End If
j.Release
 
Upvote 0
Top