Search in sources :

Example 66 with BasicClientCookie

use of org.apache.http.impl.cookie.BasicClientCookie in project spring-framework by spring-projects.

the class MockMvcWebConnection method createCookie.

private static com.gargoylesoftware.htmlunit.util.Cookie createCookie(jakarta.servlet.http.Cookie cookie) {
    Date expires = null;
    if (cookie.getMaxAge() > -1) {
        expires = new Date(System.currentTimeMillis() + cookie.getMaxAge() * 1000);
    }
    BasicClientCookie result = new BasicClientCookie(cookie.getName(), cookie.getValue());
    result.setDomain(cookie.getDomain());
    result.setComment(cookie.getComment());
    result.setExpiryDate(expires);
    result.setPath(cookie.getPath());
    result.setSecure(cookie.getSecure());
    if (cookie.isHttpOnly()) {
        result.setAttribute("httponly", "true");
    }
    return new com.gargoylesoftware.htmlunit.util.Cookie(result);
}
Also used : BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie) Cookie(com.gargoylesoftware.htmlunit.util.Cookie) BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie) Date(java.util.Date)

Example 67 with BasicClientCookie

use of org.apache.http.impl.cookie.BasicClientCookie in project Libraries-for-Android-Developers by eoecn.

the class SerializableCookie method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
Also used : BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie)

Example 68 with BasicClientCookie

use of org.apache.http.impl.cookie.BasicClientCookie in project SmartAndroidSource by jaychou2012.

the class SerializableCookie method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
Also used : BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie)

Example 69 with BasicClientCookie

use of org.apache.http.impl.cookie.BasicClientCookie in project openkit-android by OpenKit.

the class SerializableCookie method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
Also used : BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie)

Example 70 with BasicClientCookie

use of org.apache.http.impl.cookie.BasicClientCookie in project undertow by undertow-io.

the class AbstractModClusterTestBase method checkGet.

static String checkGet(final String context, int statusCode, String route) throws IOException {
    final HttpGet get = get(context);
    if (route != null && getSessionRoute() == null) {
        BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "randomSessionID." + route);
        httpClient.getCookieStore().addCookie(cookie);
    }
    final HttpResponse result = httpClient.execute(get);
    final String response = HttpClientUtils.readResponse(result);
    Assert.assertEquals(statusCode, result.getStatusLine().getStatusCode());
    if (route != null) {
        Assert.assertEquals(route, getSessionRoute());
    }
    return response;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie)

Aggregations

BasicClientCookie (org.apache.http.impl.cookie.BasicClientCookie)88 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)36 Test (org.junit.Test)24 HttpResponse (org.apache.http.HttpResponse)19 Cookie (org.apache.http.cookie.Cookie)17 HttpClient (org.apache.http.client.HttpClient)15 HttpGet (org.apache.http.client.methods.HttpGet)15 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)15 Map (java.util.Map)14 RequestConfig (org.apache.http.client.config.RequestConfig)13 HttpPost (org.apache.http.client.methods.HttpPost)9 CookieAttributeHandler (org.apache.http.cookie.CookieAttributeHandler)9 CookieOrigin (org.apache.http.cookie.CookieOrigin)9 URL (java.net.URL)8 HttpEntity (org.apache.http.HttpEntity)8 CookieStore (org.apache.http.client.CookieStore)8 IOException (java.io.IOException)7 Date (java.util.Date)7 ClientCookie (org.apache.http.cookie.ClientCookie)7 HashMap (java.util.HashMap)6