Bug? DownloadService/HttpJob and HttpUtil2

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I have met a problem in using the above mentioned modules.
1) I have an app using "normal" HttpJob and HttpUtil2Service modules. For "Normal" I mean the modules found when they were originally introduced in the site. This app work fine, Posts and receives answers from a WebService.
2) I decided to add a Download feature (download a pdf manual), so I went here to find something useful and found the LargeFileDownload example.
3) It is using "same" additional modules, apparently, so I thought to use the modules used in (1) and not those posted with the LargeFileDowload example. Moreover, at a file compare, they were "very similar" (I know that to tell this is funny in programming topics).
4) As a matter of fact I got and error in compilation.
5) To find a quick solution, I substituted the two modules in my original App with those included in LargeFileDownload project. So, at this point, the HttpJob and HttpUil2Service are these latter.
6) App compiles and, as expected, executes the download, but crashes in old operations.
I attach the log.
Thanks if anybody can help.
 

Attachments

  • log.txt
    1.6 KB · Views: 210

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Moreover, if I modify HttpUtil2Service function hc_ResponseSuccess (where the crash of previous message happens), putting it equal to the previous (and working for normal operations) version, now normal operations work and download crashes.
Modified function is (The comment "modified code" is in the original file, not mine: I just commented all the lines, and adding the only not commented line, taken by the original HttpUtil2Service file):
Sub hc_ResponseSuccess (Response AsHttpResponse, TaskId AsInt)
' ********** Modified code *************
'Dim cs As CountingOutputStream
'cs.Initialize(File.OpenOutput(TempFolder, TaskId, False))
'Dim j As HttpJob = TaskIdToJob.Get(TaskId)
'Dim jt As JobTag = j.Tag
'jt.CountingStream = cs
'jt.Total = Response.ContentLength
'If jt.Data.url = "" Then
' Log("Job cancelled before downloaded started")
' cs.Close
'End If
'Response.GetAsynchronously("response", cs , True, TaskId)
'**************************************
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), True, TaskId)
End Sub
And log for this case is attached.
 

Attachments

  • log_commented.txt
    1.8 KB · Views: 178

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Further investigation reveals that the problem is in the "accessory" display of the progress bar.
The very first solution is to take away the progressbar functions. As a matter of fact, commenting one line as follows, resolves (but not progress bar updating happens):
Sub JobDone(job AsHttpJob)
jobs.Remove(job.JobName)
Dim jt AsJobTag = job.Tag
Ifjobs.Size = 0Then EndTimer
If job.Success Then
'CallSubDelayed3(jt.Data.Target, jt.Data.EventName & "_Progress", jt.CountingStream.Count, jt.Total) '<<<<<<<< commented out line: this crashes
CallSubDelayed2(jt.Data.Target, jt.Data.EventName & "_Complete", job)
Else
Log(job.ErrorMessage)
CallSubDelayed2(jt.Data.Target, jt.Data.EventName & "_Complete", job)
EndIf
End Sub

For my use the ProgressBar is not important, being my file actually rather small. Anyway the problem remains, in general. I am not able to fix the general problem, at least at the moment...
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Other considerations (Perhaps my analysis is rude, but I did my best to give elements of investigation..)
Now using the HttpUtil2Service of the LargeFileDownload. So the hc_ResponseSuccess is without comments, like the following:
Sub hc_ResponseSuccess (Response AsHttpResponse, TaskId AsInt)
' ********** Modified code *************
Dim cs AsCountingOutputStream
cs.Initialize(File.OpenOutput(TempFolder, TaskId, False))
Dim j As HttpJob = TaskIdToJob.Get(TaskId)
Dim jt As JobTag = j.Tag '##
jt.CountingStream = cs '<<< here Log displays "java.lang.RuntimeException: Field: CountingStream not found in: java.lang.Object"
jt.Total = Response.ContentLength
If jt.Data.url = ""Then
Log("Job cancelled before downloaded started")
cs.Close
EndIf
Response.GetAsynchronously("response", cs , True, TaskId)
'**************************************
'Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), True, TaskId)
End Sub

But, for what I see, CountingStream is declared in JobTag in Process Globals of DownloadService:

TypeJobTag (Data AsDownloadData, CountingStream AsCountingOutputStream, Total AsLong)

So the error sounds strange to me. Further investigation indicates that the assignment: jt=j.Tab (marked ## above) is reponsible for the problem. As a matter of fact, if again I comment out the assignment, program doesn't crash in the previous line, but, obviously, elsewhere, missing evidently the information given by the assignment..
Thanks for your attention.
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi Erel, sorry for late reply.
In previous messages, I attached the logs (as copy/pasted in NotePad) in the two cases described. There appear the errors.
Thanks.
Giovanni
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Sorry Erel, but the code attached to the post that you reported in previous mail is the same I used.
Also, at the end of that post, this sentence makes things not clear:"As this is a modified version of HttpUtils2 you should not reference HttpUtils2 library. You should instead add the three modules from the attached project. Note that the modified code is in Sub hc_ResponseSuccess."
Sincerely, for me, things are not clear. Perhaps my previous posts were not clear.
I can only add to what I already wrote, that I either "used the old version of the .bas modules" or "used the new ones". I never used the library, due to the abovementioned sentence. I can make further experiments, but perhaps you should clarify further the situation.
Thanks
Giovanni
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I repeat, for further clarification: the modules of that post correctly do the download but crash with Posts made using previous code, while old modules crash doing download. All the modules were found in the site and I dodn't modify anything.
 
Top