Example usage for org.apache.http.cookie Cookie getClass

List of usage examples for org.apache.http.cookie Cookie getClass

Introduction

In this page you can find the example usage for org.apache.http.cookie Cookie getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:eu.masconsult.bgbanking.utils.CookieQuotesFixerResponseInterceptor.java

@Override
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
    CookieStore cookieStore = (CookieStore) context.getAttribute(ClientContext.COOKIE_STORE);
    for (Header header : response.getAllHeaders()) {
        if (!header.getName().equalsIgnoreCase("Set-Cookie")) {
            continue;
        }//  w ww. ja  v  a  2s  . c  o m
        Matcher matcher = pattern.matcher(header.getValue());
        if (!matcher.find()) {
            continue;
        }
        for (Cookie cookie : cookieStore.getCookies()) {
            if (cookie.getName().equalsIgnoreCase(matcher.group(1))) {
                if (cookie instanceof BasicClientCookie) {
                    ((BasicClientCookie) cookie).setValue('"' + cookie.getValue() + '"');
                } else if (cookie instanceof BasicClientCookie2) {
                    ((BasicClientCookie2) cookie).setValue('"' + cookie.getValue() + '"');
                } else {
                    Log.w(TAG, "unhandled cookie implementation " + cookie.getClass().getName());
                }
                break;
            }
        }
    }
}

From source file:com.blazeroni.reddit.http.PersistentCookieStore.java

@Override
public void addCookie(Cookie cookie) {
    String name = cookie.getName();

    Date expiryDate = cookie.getExpiryDate();
    if (Log.DEBUG) {
        Log.debug("cookie value: " + cookie.getValue());
        Log.debug("Expiry date: " + (expiryDate == null ? "no expiry date" : expiryDate.toLocaleString()));
        Log.debug("persistent: " + cookie.isPersistent());
        Log.debug("Cookie class: " + cookie.getClass().getCanonicalName());
    }/*  w  w  w.  j av  a2s .com*/

    // Save cookie into local store
    this.cookies.put(name, cookie);

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = this.cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", this.cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();

}