If you are using the same HttpClient object for all the requests, the
cookie handling should be done for you automatically. If you want to
change the value of Cookies or add additional ones, then use
DefaultHttpClient.getCookieStore() and manipulate them from there.
Cheers,
Justin
Android Team @ Google
On Aug 27, 6:59 am, Graeme <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm trying to write a HttpClient 4.x application in which
>
> a) I extract Cookies from a HTTP Response (following an initial HTPP
> POST),
> b) put the Cookie in the next outgoing request (another HTTP POST
> method),
> c) get the Cookie(s) from the resulting Response,
> d) put the Cookie(s) in the next outgoing Request,
> .... etc. until end of my HTTP sequence.
>
> How do I do this in Android's version of HttpClient 4.x ? I think I
> need to use Request Interceptors and Response Interceptors. Does
> anyone have experience with this ?
> I am currently trying
>
> DefaultHttpClient dhc = new DefaultHttpClient() ;
>
> // Response Interceptor to extract Cookies from Responsies and add
> toCookieStore
> dhc.addResponseInterceptor( new ResponseProcessCookies() );
>
> // Request Interceptor to add Cookies fromCookieStoreto outgoing
> Requests
> dhc.addRequestInterceptor( new RequestAddCookies() );
>
> // Create a HttpPost
> HttpPost post1= new HttpPost("some-url-or-other");
>
> // Send first request & get response
> HttpResponse rsp1 = dhc.execute( post1 );
>
> //Create second HttpPost
> HttpPost post2 = new HttpPost("some-url-or-other");
>
> //Send the seconfd POST and get a response
> HttpResponse rsp2 = dhc.execute( post2 );
>
> etc.
>
> BTW Am I able to examine the contensts of theCookieStore? (If so,
> how ?)
>
> Thanks for any pointers
> Graeme
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---