Search in sources :

Example 1 with UrlEncodedFormEntity

use of cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity in project AndroidStudy by tinggengyan.

the class HttpCookie method run.

@Override
public void run() {
    list.add(new BasicNameValuePair("name", "steve"));
    list.add(new BasicNameValuePair("age", "12"));
    try {
        post.setEntity(new UrlEncodedFormEntity(list));
        HttpResponse response = client.execute(post);
        if (response.getStatusLine().getStatusCode() == 200) {
            AbstractHttpClient absclient = (AbstractHttpClient) client;
            List<Cookie> cookies = absclient.getCookieStore().getCookies();
            for (Cookie cookie : cookies) {
                System.out.println("name==" + cookie.getName());
                System.out.println("value==" + cookie.getValue());
                Message message = new Message();
                message.obj = cookie;
                mHandler.sendMessage(message);
                return;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AbstractHttpClient(cz.msebera.android.httpclient.impl.client.AbstractHttpClient) Cookie(cz.msebera.android.httpclient.cookie.Cookie) Message(android.os.Message) BasicNameValuePair(cz.msebera.android.httpclient.message.BasicNameValuePair) HttpResponse(cz.msebera.android.httpclient.HttpResponse) UrlEncodedFormEntity(cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity)

Aggregations

Message (android.os.Message)1 HttpResponse (cz.msebera.android.httpclient.HttpResponse)1 UrlEncodedFormEntity (cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity)1 Cookie (cz.msebera.android.httpclient.cookie.Cookie)1 AbstractHttpClient (cz.msebera.android.httpclient.impl.client.AbstractHttpClient)1 BasicNameValuePair (cz.msebera.android.httpclient.message.BasicNameValuePair)1