Android Question Download problem

rboeck

Well-Known Member
Licensed User
Longtime User
Hi,

my app is inside an mobile telephonbook site; i transmit name and adress to the site;
after an adress was choosen, there is the possibility for storing this adress in vcf format.

The url i get in Webview1_OverrideUrl is:
http://mobil.dasoertliche.de/;logsection=vCard;logtitle=Download/fit:extension/vcard.vcf?id=vCard

My current code is this:
B4X:
Dim Job As HttpJob
Job.Initialize("Job",Me)
Job.Download(URL1)
ProcessHTML(URL1)

With this code i get the vcf file not as file, than as text in smallest possible chars...
Then i get a toast message: Error: Internal Server Error
My Know How of webtechnologie is not enough to handle this result.
Any hints?
 
Last edited:

rboeck

Well-Known Member
Licensed User
Longtime User
Sorry, I was unable to ask exactly: the upper code is processed for starting the download job. When i use this statement: ProcessHTML i get the internal Server Error in JobDone Event ; if i dont use this one line, i see the vcf file inside my webview in the smallest possible size and JobDone is never used.
I tried to use the same mobile web adress with chrome on android and get the same result: the file source is shown as text file.
When i use a desktop browser, i get the an normal download dialog.
The mobile website is:
http://mobil.dasoertliche.de
Here you can choose on adress and click on "Ins Adressbuch"

An swiss and an austrian variant of the almost same problem are running.

Reinhard
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Hi, i is easier for you to show it in B4J: You get a german telefonbook, click on a adress. On the following page there is a label: Ins Adressbuch

In line 36 to 38 there is code for starting the download, but it leads to an Internal Server error; what can i do, to download this file?

Reinhard
 

Attachments

  • tbook.zip
    1.3 KB · Views: 192
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
I think this error is only here, when you wait for a longer time or change to another browser. If you stay inside one session you dont get the error.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Ok. I understand. The problem is that you need to send the session cookies together with the request. You can use this (B4A) library to get the cookies: [lib] CookieManager

You will need to then add the cookies to the request.
B4X:
Job.Download(...)
Job.GetRequest.SetHeader("Cookie", <cookies>) 'make sure to add a reference to Http library.
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
It works!
Many thanks to you and warwound for the library.

One last question (for today): I tried to use the cookieManager from B4J - the lib was shown, but Dim of the manager was not possible. Is there recompilation needed?
 
Upvote 0
Top