Example usage for org.apache.commons.httpclient Cookie getComment

List of usage examples for org.apache.commons.httpclient Cookie getComment

Introduction

In this page you can find the example usage for org.apache.commons.httpclient Cookie getComment.

Prototype

public String getComment() 

Source Link

Usage

From source file:GetCookiePrintAndSetValue.java

public static void main(String args[]) throws Exception {

    HttpClient client = new HttpClient();
    client.getParams().setParameter("http.useragent", "My Browser");

    GetMethod method = new GetMethod("http://localhost:8080/");
    try {/*from w ww. j a v  a2s . com*/
        client.executeMethod(method);
        Cookie[] cookies = client.getState().getCookies();
        for (int i = 0; i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            System.err.println("Cookie: " + cookie.getName() + ", Value: " + cookie.getValue()
                    + ", IsPersistent?: " + cookie.isPersistent() + ", Expiry Date: " + cookie.getExpiryDate()
                    + ", Comment: " + cookie.getComment());

            cookie.setValue("My own value");
        }
        client.executeMethod(method);
    } catch (Exception e) {
        System.err.println(e);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.owncloud.android.lib.common.OwnCloudClient.java

@SuppressWarnings("unused")
private void logCookie(Cookie cookie) {
    Log_OC.d(TAG, "Cookie name: " + cookie.getName());
    Log_OC.d(TAG, "       value: " + cookie.getValue());
    Log_OC.d(TAG, "       domain: " + cookie.getDomain());
    Log_OC.d(TAG, "       path: " + cookie.getPath());
    Log_OC.d(TAG, "       version: " + cookie.getVersion());
    Log_OC.d(TAG, "       expiryDate: "
            + (cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
    Log_OC.d(TAG, "       comment: " + cookie.getComment());
    Log_OC.d(TAG, "       secure: " + cookie.getSecure());
}

From source file:com.cerema.cloud2.lib.common.OwnCloudClient.java

private void logCookie(Cookie cookie) {
    Log_OC.d(TAG, "Cookie name: " + cookie.getName());
    Log_OC.d(TAG, "       value: " + cookie.getValue());
    Log_OC.d(TAG, "       domain: " + cookie.getDomain());
    Log_OC.d(TAG, "       path: " + cookie.getPath());
    Log_OC.d(TAG, "       version: " + cookie.getVersion());
    Log_OC.d(TAG, "       expiryDate: "
            + (cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
    Log_OC.d(TAG, "       comment: " + cookie.getComment());
    Log_OC.d(TAG, "       secure: " + cookie.getSecure());
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.DocumentTest.java

private void checkCookie(final Cookie cookie, final String name, final String value, final String path,
        final String domain, final boolean secure, final Date date) {
    assertEquals(name, cookie.getName());
    assertEquals(value, cookie.getValue());
    assertNull(cookie.getComment());
    assertEquals(path, cookie.getPath());
    assertEquals(domain, cookie.getDomain());
    assertEquals(secure, cookie.getSecure());
    assertEquals(date, cookie.getExpiryDate());
}

From source file:org.mule.transport.http.CookieHelper.java

/**
 * This method formats the cookie so it can be send from server to client in a
 * {@linkplain HttpConstants#HEADER_COOKIE_SET "Set-Cookie"} header.
 *//*from w w  w  .j  av  a2 s .c  o  m*/
public static String formatCookieForASetCookieHeader(Cookie cookie) {
    StringBuffer sb = new StringBuffer();
    ServerCookie.appendCookieValue(sb, cookie.getVersion(), cookie.getName(), cookie.getValue(),
            cookie.getPath(), cookie.getDomain(), cookie.getComment(), -1, cookie.getSecure());

    Date expiryDate = cookie.getExpiryDate();
    if (expiryDate != null) {
        sb.append("; Expires=");
        sb.append(EXPIRE_FORMATTER.format(expiryDate));
    }

    return sb.toString();
}