iOS Question Error occurred on line: 98 (HttpUtils2Service)

Status
Not open for further replies.

aarroyo

Member
Licensed User
Longtime User
Good evening, everyone I am having a problem that is driving me a little crazy, it turns out that when I download an image with imagendownloader, if it does not exist, the program breaks, but only if it is from certain servers, from others it does not

Ejem: https://manchanet.es/nothing.jpg -> Break
https://yolopido.es/nothing.jpg - > No break


Has this happened to someone?



Ggreetings
Antonio
 

Attachments

  • Captura2.PNG
    Captura2.PNG
    101.1 KB · Views: 193

aarroyo

Member
Licensed User
Longtime User
Good morning, I've created an example with and keeps giving the same mistake,

Example:
Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 7
#End Region
   #CertificateFile: ios_development.cer
   #ProvisionFile: DefaultDevelopment.mobileprovision
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private ImageView1 As ImageView
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    DownloadImage(ImageView1, "https://www.manchanet.es/nothing.png")
   
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   
End Sub

Private Sub Application_Background
   
End Sub
Sub DownloadImage(iv As ImageView,Link As String)
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(Link)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        iv.Bitmap = j.GetBitmap
    End If
    j.Release
End Sub
 

Attachments

  • error.JPG
    error.JPG
    95.4 KB · Views: 203
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
An error occurs inside HttpUtils2Service.Bas

B4X:
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Log("ResponseError: " & Reason & ", status code: " & StatusCode)
    Dim j As String = Response.GetString
    If j <> "" Then Reason = j
    CompleteJob(TaskId, False, Reason, Response)
End Sub

Guess, Erel sooner or later will correct iHttp. But it's enough simple to supress this error anyway.
For example, find iHttpUtils2.b4xlib inside C:\Program Files (x86)\Anywhere Software\B4i\Libraries and rename to iHttpUtils2.zip.
Extract HttpUtils2Service.Bas and change Dim j As String = Response.GetString to
B4X:
    Dim j As String
    If StatusCode <> 404 Then j = Response.GetString
Update zip-file and return original name (iHttpUtils2.b4xlib).
 
Upvote 0
Status
Not open for further replies.
Top