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

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

Introduction

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

Prototype

String getValue();

Source Link

Document

Returns the value.

Usage

From source file:io.undertow.servlet.test.session.GetRequestedSessionIdTestCase.java

private String getSession(List<Cookie> cookies) {
    for (Cookie cookie : cookies) {
        if (cookie.getName().equals("JSESSIONID")) {
            return cookie.getValue();
        }//from w  w w  .  ja  va  2s  .  c o  m
    }
    return null;
}

From source file:com.heyzap.http.SDKCookieStore.java

public String getCookieString(Cookie cookie) {
    String cookieString = String.format("%s=%s", cookie.getName(), cookie.getValue());
    return cookieString;
}

From source file:ilarkesto.integration.max.internet.RequestExecutor.java

private String getCookieValue(String name) {
    CookieStore cookieStore = httpClient.getCookieStore();
    for (Cookie cookie : cookieStore.getCookies()) {
        if (name.equals(cookie.getName()))
            return cookie.getValue();
    }/* w w w .  ja v a  2s .  co m*/
    return null;
}

From source file:org.exoplatform.utils.image.CookieAwarePicassoDownloader.java

/**
 * Syncs all cookies from ExoConnectionUtils cookieStore from Apache's
 * HttpClient to HttpURLConnection./*  ww w.j  a v a2 s  . co m*/
 * 
 * @param manager the CookieManager in which to store the retrieved cookies
 */
private void syncCookies(CookieManager manager) {
    CookieStore store = ExoConnectionUtils.cookiesStore;
    if (store == null)
        return;

    for (Cookie cookie : store.getCookies()) {
        HttpCookie c = new HttpCookie(cookie.getName(), cookie.getValue());
        c.setDomain(cookie.getDomain());
        c.setPath(cookie.getPath());
        c.setVersion(cookie.getVersion());
        String url = AccountSetting.getInstance().getDomainName() + "/" + cookie.getPath();
        try {
            manager.getCookieStore().add(new URI(url), c);
        } catch (URISyntaxException e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }
}

From source file:de.devbliss.apitester.TestState.java

/**
 * Get the value of the cookie with the given name, if one can be found.  Note, it is
 * possible that there might be multiple cookies with the same name, this will just
 * return the first one found.//from  w w w.j a  va  2 s.  c om
 *
 * @param name The name of the cookie
 * @return The value of the cookie, or null if no cookie with that name was found
 */
public String getCookieValue(String name) {
    for (org.apache.http.cookie.Cookie cookie : cookieStore.getCookies()) {
        if (cookie.getName().equals(name)) {
            return cookie.getValue();
        }
    }
    return null;
}

From source file:de.koczewski.maxapi.RequestExecutor.java

public String getCookieValue(String name) {
    CookieStore cookieStore = httpClient.getCookieStore();
    for (Cookie cookie : cookieStore.getCookies()) {
        if (name.equals(cookie.getName()))
            return cookie.getValue();
    }/*from ww  w . j  a  v  a2 s  . c o m*/
    return null;
}

From source file:com.ryan.ryanreader.cache.PersistentCookieStore.java

public synchronized byte[] toByteArray() {

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DataOutputStream dos = new DataOutputStream(baos);

    try {//w  w w  . j a v  a2 s.  c  om

        dos.writeInt(cookies.size());

        for (final Cookie cookie : cookies) {

            dos.writeUTF(cookie.getName());
            dos.writeUTF(cookie.getValue());
            dos.writeUTF(cookie.getDomain());
            dos.writeUTF(cookie.getPath());
            dos.writeBoolean(cookie.isSecure());
        }

        dos.flush();
        dos.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return baos.toByteArray();
}

From source file:gmusic.api.comm.ApacheConnector.java

private String getCookieValue(String cookieName) {
    for (Cookie cookie : cookieStore.getCookies()) {
        if (cookie.getName().equals(cookieName)) {
            return cookie.getValue();
        }/*ww  w  .j  av a 2 s  .c o  m*/
    }
    return null;
}

From source file:cookies.SessionIT.java

@Test
public void noCookiesOnAsset() throws Exception {
    HttpResponse<String> response = get("/session").asString();
    Cookie session = response.cookie("wisdom_SESSION");
    assertThat(session).isNotNull();/*w  ww. j ava  2  s.c o m*/
    assertThat(session.getPath()).isEqualTo("/");
    assertThat(session.getValue()).contains("foo=bar").contains("baz=bah").contains("blah=42");

    HttpResponse<InputStream> resp = get("/assets/empty.txt").asBinary();
    assertThat(resp.code()).isEqualTo(OK);
    assertThat(resp.header(SET_COOKIE)).isNull();

    response = get("/session/clear").asString();
    session = response.cookie("wisdom_SESSION");
    // Session cleared... no more cookie.
    assertThat(session).isNull();
}

From source file:cookies.SessionIT.java

@Test
public void testSessionManipulation() throws Exception {
    HttpResponse<String> response = get("/session").asString();
    Cookie session = response.cookie("wisdom_SESSION");
    assertThat(session).isNotNull();//from w  w w .  ja va  2s.co m
    assertThat(session.getPath()).isEqualTo("/");
    assertThat(session.getValue()).contains("foo=bar").contains("baz=bah").contains("blah=42");

    response = get("/session").asString();
    session = response.cookie("wisdom_SESSION");
    // blah removed
    assertThat(session.getValue()).contains("foo=bar").contains("baz=bah").doesNotContain("blah");

    response = get("/session/clear").asString();
    session = response.cookie("wisdom_SESSION");
    // Session cleared... no more cookie.
    assertThat(session).isNull();
}