Android Question Download HTML files with session

Nickelgrass

Active Member
Licensed User
Longtime User
Hi,
I have a big problem loading HTML files from the internet. Usually I use httpclient with initializeacceptall to load files. This works fine and I can also log in to pages using a login in the get header URL.

Now I have a problem that a page refuses to log me in and always returns me the login page. It uses some post data for the username and password. I tried it with a webview that worked. I assume it uses a session. So when I load the second page (with the httpclient), the session from the first page is expired. (And yes I considered to use HTTPuntils2 which doesnt work because I nee the acceptall.)

I have searched a lot in this forum but could not find a working solution. I would need a httpclient that keeps the session data. Or I would need to place a non visible webview and control the login with the post data from my code and then get the html from the webview for parsing. There were some examples for getting the html code with the webview extras but I could not get it to work.

How can I get the html pages and post the login data with the post method?

Thanks a lot!

Regards
 
Last edited:

Nickelgrass

Active Member
Licensed User
Longtime User
After doing a bit more research I have finally found out that all I would have to do is get the cookie data out from the returned header and include it with the following requests.
So now after looking up some posts in the forum I saw that this is only possible by modifying the Httputils2 wich gives me 2 new problems. How do I modify the Httputils2 to give me the headers and how do I get Httputils2 to be able of "Intitializeacceptall" ?
Or is it (preferably) possible to modify the HTTP library and httpclient to also pass a second string with the headers?
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
Works perfect! Thanks for the hint with the response object GetHeaders. I always thought of it as a simple string, I am ashamed that I mistakend that :oops: :mad:
It worked by simply parsing the cookie string from one httprequest and inserting it in the second (with httpclient).
:D:D:D
 
Upvote 0
Top