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.