android2.2 的cookie

public static void getCookies(HttpResponse httpResponse)
    {
     Header[] headers = httpResponse.getHeaders("Set-Cookie");
     String headerstr=headers.toString();
        if (headers == null)
            return;

        for(int i=0;i<headers.length;i++)
        {
         String cookie=headers[i].getValue();
         String[]cookievalues=cookie.split(";");
         for(int j=0;j<cookievalues.length;j++)
         {
          String[] keyPair=cookievalues[j].split("=");
          String key=keyPair[0].trim();
          String value=keyPair.length>1?keyPair[1].trim():"";
          Log.d("cookie",key+"="+value);
         }
        }
       
        Header[] cookie=httpResponse.getAllHeaders();
  for(int i=0; i<cookie.length;i++){
   Log.d("Test", "Cookie--"+i+"---------->"+cookie[i].getName()+"="+cookie[i].getValue());
  }
  //..............................................
       
       
    }

你可能感兴趣的:(android)