I don't see how the headers will help here. The string you see is an error message. It is not HTML. Can you post the code that handles the response (JobDone)?
here was the original code:
Sub JobDone( Job As httpjob )
ProgressDialogHide
If Job.Success = False Then
Msgbox("Sorry: (" & Job.JobName & ") " & Job.ErrorMessage,"")
Else
Select Job.JobName
Case "TheImg"
Dim bm As Bitmap
bm.Initialize3( Job.GetBitmap )
' do some stuff with bm then feed to imageview.bitmap
...
i never see the msgbox telling me the job.success = false, so that means success = true, right? i initialize3 the expected bitmap to job.getbitmap and continue on from there. yet i received an unitialized bitmap error message.
here's the way i look at it: the request for an image receives a code 200 from the server, but the server sends a burst of html text which i can see plainly in the log. so job.success = true and httputils2.getbitmap tries to loadbitmap from its temp folder. but what's in that file isn't a bitmap. bitmap.initialize3() doesn't offer me any return value. maybe i should test for null at that point? is that what job.getbitmap returns? the httputils2 documentation says it returns a bitmap. it doesn't say what it returns
in the event of failure. (to my mind, "returns a bitmap" means "returns a pointer to a bitmap struct, or null".) i don't know how b4a or java handle things like that.
in the meantime, and before you replied, i went ahead and changed my code to include a "try/catch", as shown below.
Sub JobDone( Job As httpjob )
ProgressDialogHide
If Job.Success = False Then
Msgbox("Sorry: (" & Job.JobName & ") " & Job.ErrorMessage,"")
Else
Select Job.JobName
Case "TheImg"
Dim bm As Bitmap
Try
bm.Initialize3( Job.GetBitmap )
Catch
Msgbox("Maybe this isn't an image...","")
Return
End Try
' do some stuff with bm
...
i think it may have had an effect. i don't see that error, and i keep testing. i also added try/catch in some other places where i access a bitmap which i had previously initialized3 and assumed was, in fact, a bitmap. there, too, try/catch stopped the error message. so maybe i answered my own question, yes? eg:
bm.Initialize3( Job.GetBitmap )
if bm = Null then
to clarify: the app generally works perfectly. this error was unexpected, especially since the job showed success = true and because i was initializing the bitmap. i did what i thought i needed to do. maybe the server should have sent code 400 or other error code. but apparently it didn't. and i wasn't ready for that.
i had wanted to see the http headers because if job.success = true but "content-type" was not "image/jpeg" or "image/...", i would use job.getstring instead of job.getbitmap to deal smoothly with unexpected content type instead of crashing.
thanks again for your time.