Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-10 Thread Massimo Messore
I had a different issue with the HttpClient lib included into the Android
sdk.

I solved using an external and newer HttpClient library in my project.

Maybe it worth a try: http://code.google.com/p/httpclientandroidlib/

Regards
Massimo
Il 10/ago/2014 07:23 Gaurav Vaish gaurav.va...@gmail.com ha scritto:

 There is no other way to add cookie, isn't it?

 Or do you mean it is my responsibility to format / combine all cookies?

 What's the purpose of CookieSpecPNames.SINGLE_COOKIE_HEADER parameter
 then?
 How do I use that?

 - Gaurav

 On Saturday, 9 August 2014 12:38:00 UTC-7, mbanzon wrote:

 You don't set a cookie - you set a header. Twice.

 It's the expected result...


 On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav...@gmail.com wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not
 work nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:

 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, true
 );

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status - 
 + response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 --
 Michael Banzon
 http://michaelbanzon.com/

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-10 Thread Gaurav Vaish
But that makes final APK fat...

I guess if there's no other option, I'll better write a thin hack in the
app.

- Gaurav
www.m10v.com

On Saturday, August 9, 2014, Massimo Messore massimo.mess...@gmail.com
wrote:

 I had a different issue with the HttpClient lib included into the Android
 sdk.

 I solved using an external and newer HttpClient library in my project.

 Maybe it worth a try: http://code.google.com/p/httpclientandroidlib/

 Regards
 Massimo
 Il 10/ago/2014 07:23 Gaurav Vaish gaurav.va...@gmail.com
 javascript:_e(%7B%7D,'cvml','gaurav.va...@gmail.com'); ha scritto:

 There is no other way to add cookie, isn't it?

 Or do you mean it is my responsibility to format / combine all cookies?

 What's the purpose of CookieSpecPNames.SINGLE_COOKIE_HEADER parameter
 then?
 How do I use that?

 - Gaurav

 On Saturday, 9 August 2014 12:38:00 UTC-7, mbanzon wrote:

 You don't set a cookie - you set a header. Twice.

 It's the expected result...


 On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav...@gmail.com
 wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not
 work nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:

 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER,
 true);

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status -
  + response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 --
 Michael Banzon
 http://michaelbanzon.com/

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 javascript:_e(%7B%7D,'cvml','android-developers@googlegroups.com');
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','android-developers%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','android-developers%2bunsubscr...@googlegroups.com');
 .
 For more options, visit https://groups.google.com/d/optout.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 javascript:_e(%7B%7D,'cvml','android-developers@googlegroups.com');
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','android-developers%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/yHZA_N4V06I/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 

Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-10 Thread Michael Banzon
It have been ages since I've messed with HTTP on Android - but as far as I
recall the DefaultHttpClient has a CookieStore - as far as I remember
cookies can be set through that.


On Sun, Aug 10, 2014 at 7:19 AM, Gaurav Vaish gaurav.va...@gmail.com
wrote:

 There is no other way to add cookie, isn't it?

 Or do you mean it is my responsibility to format / combine all cookies?

 What's the purpose of CookieSpecPNames.SINGLE_COOKIE_HEADER parameter
 then?
 How do I use that?

 - Gaurav


 On Saturday, 9 August 2014 12:38:00 UTC-7, mbanzon wrote:

 You don't set a cookie - you set a header. Twice.

 It's the expected result...


 On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav...@gmail.com wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not
 work nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:

 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, true
 );

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status - 
 + response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com

 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 --
 Michael Banzon
 http://michaelbanzon.com/




-- 
Michael Banzon
http://michaelbanzon.com/

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-10 Thread Gaurav Vaish
Ah... I see. How did I miss that...

Thnx for the pointer.

- Gaurav

On Sunday, 10 August 2014 04:03:10 UTC-7, mbanzon wrote:

 It have been ages since I've messed with HTTP on Android - but as far as I 
 recall the DefaultHttpClient has a CookieStore - as far as I remember 
 cookies can be set through that.


 On Sun, Aug 10, 2014 at 7:19 AM, Gaurav Vaish gaurav...@gmail.com 
 javascript: wrote:

 There is no other way to add cookie, isn't it?

 Or do you mean it is my responsibility to format / combine all cookies?

 What's the purpose of CookieSpecPNames.SINGLE_COOKIE_HEADER parameter 
 then?
 How do I use that?

 - Gaurav


 On Saturday, 9 August 2014 12:38:00 UTC-7, mbanzon wrote:

 You don't set a cookie - you set a header. Twice.

 It's the expected result...


 On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav...@gmail.com 
 wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not 
 work nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:
  
 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, 
 true);

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status - 
  + response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as 
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com

 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Michael Banzon
 http://michaelbanzon.com/ 




 -- 
 Michael Banzon
 http://michaelbanzon.com/ 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-09 Thread Michael Banzon
You don't set a cookie - you set a header. Twice.

It's the expected result...


On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav.va...@gmail.com wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not work
 nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:

 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, true);

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status -  +
 response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Michael Banzon
http://michaelbanzon.com/

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] DefaultHttpClient / AndroidHttpClient - Multiple Cookie Headers

2014-08-09 Thread Gaurav Vaish
There is no other way to add cookie, isn't it?

Or do you mean it is my responsibility to format / combine all cookies?

What's the purpose of CookieSpecPNames.SINGLE_COOKIE_HEADER parameter then?
How do I use that?

- Gaurav

On Saturday, 9 August 2014 12:38:00 UTC-7, mbanzon wrote:

 You don't set a cookie - you set a header. Twice.

 It's the expected result...


 On Sat, Aug 9, 2014 at 9:08 PM, Gaurav Vaish gaurav...@gmail.com 
 javascript: wrote:

 Hi,

 I noticed that DefaultHttpClient as well as AndroidHttpClient do not work 
 nicely if multiple Cookie or Cookie2 headers are set in a request.

 I tried with a simple test code:
  
 String url = http://www.myserver.com;;
 DefaultHttpClient dhc = new DefaultHttpClient();
 HttpParams hparams = dhc.getParams();
 hparams.setParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, true
 );

 HttpGet req =new HttpGet(url);

 req.addHeader(Cookie, A=B);
 req.addHeader(Cookie, C=D);
 req.addHeader(User-Agent, AndroidExp/ApacheHttpClient);

 try {
 HttpResponse response = dhc.execute(req);
 message = (response == null) ? No response : (Status -  
 + response.getStatusLine().getStatusCode());
 } catch(Exception e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 } catch(RuntimeException e) {
 message = e.getClass().getName() +  =  + e.getMessage();
 e.printStackTrace();
 }


 And then monitored via Charles Proxy. The request being created is as 
 follows:

 GET / HTTP/1.1
 Cookie: A=B
 Cookie: C=D
 User-Agent: AndroidExp/ApacheHttpClientTask

 As per HTTP spec, there can be only one Cookie header.
 The same happens with AndroidHttpClient as well.

 Do I have a wrong config or did I just find a bug in the code?

 Any pointers will be useful.

 - Gaurav
 www.m10v.com


  -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com 
 javascript:
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to android-developers+unsubscr...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Michael Banzon
 http://michaelbanzon.com/ 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.