Java 8 HttpCookie - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HttpCookie class.

This code example shows how to use the following methods:
 
    public Order(int orderId) { 
        this.orderId = orderId; 
 
        /* a contrived example of calling GetUserAccount again */ 
        user = new GetUserAccountCommand(new HttpCookie("mockKey", "mockValueFromHttpRequest")).execute(); 
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:
        return header(name, DateHelper.rfc1123Format(value));
    } 
 
    @Override 
    public StubHttpResponse cookie(HttpCookie httpCookie) {
        cookies.add(httpCookie);
        return this;
    } 
 
    public StubHttpResponse cookie(String name, String value) {
        return cookie(new HttpCookie(name, value));
    } 
 
    public String header(String name) {
        return headers.get(name);
    } 
 
    @Override 
    public boolean containsHeader(String name) {
        return headers.containsKey(name);
7
CodeRank
This code example shows how to use the following methods:setMaxAge
6
CodeRank
This code example shows how to use the following methods:getComment, getCommentURL, getDiscard, getMaxAge, getName
This code example shows how to use the following methods:getSecure, setSecure, setVersion
     * @tests java.net.HttpCookie#getSecure(), setSecure(boolean) 
     *  
     * @since 1.6 
     */ 
    public void test_Get_SetSecure() { 
        HttpCookie cookie = new HttpCookie("testName", "value");
        assertFalse(cookie.getSecure());
        cookie.setVersion(0);
        assertFalse(cookie.getSecure());
 
        cookie.setSecure(true);
        assertTrue(cookie.getSecure());
        cookie.setSecure(false);
        cookie.setVersion(1);
        assertFalse(cookie.getSecure());
    } 
 
    /** 
     * @tests java.net.HttpCookie#getPath(), setPath(String) 
     *  
6
CodeRank
This code example shows how to use the following methods:getName, getValue
            if (builder == null)
                builder = new StringBuilder();
            if (builder.length() > 0)
                builder.append("; ");
            HttpCookie cookie = cookies.get(i);
            builder.append(cookie.getName()).append("=").append(cookie.getValue());
        } 
        return builder;
    } 
 
    private void applyAuthentication(Request request, URI uri)
    { 
        if (uri != null)
        { 
            Authentication.Result result = getHttpClient().getAuthenticationStore().findAuthenticationResult(uri);
            if (result != null)
                result.apply(request);
        } 
    } 
 
5
CodeRank
This code example shows how to use the following methods:
 
    public Order(int orderId) { 
        this.orderId = orderId; 
 
        /* a contrived example of calling GetUserAccount again */ 
        user = new GetUserAccountCommand(new HttpCookie("mockKey", "mockValueFromHttpRequest")).execute(); 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
 
    public Order(int orderId) { 
        this.orderId = orderId; 
 
        /* a contrived example of calling GetUserAccount again */ 
        user = new GetUserAccountCommand(new HttpCookie("mockKey", "mockValueFromHttpRequest")).execute(); 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
		String domain = NetHelper.getDomain(url);
		 
		CookieStore store = manager.getCookieStore();
 
		try { 
			HttpCookie cookie = new HttpCookie(key, value);
			store.add(new URI(domain), cookie);
		} catch (URISyntaxException e) {
			Log.e(TAG, e.getMessage());
			e.printStackTrace();
		} 
	} 
	 
	@SuppressWarnings("unchecked") 
	public void addCookies(String url, Map<String, String> cookies) {
		if ((url == null) || (cookies == null) || (cookies.size() == 0)) {
			return; 
		} 
 
		String domain = NetHelper.getDomain(url);
4
CodeRank
This code example shows how to use the following methods:getName
 
    private List<HttpCookie> sortedCopy(List<HttpCookie> cookies) {
        List<HttpCookie> result = new ArrayList<HttpCookie>(cookies);
        Collections.sort(result, new Comparator<HttpCookie>() {
            public int compare(HttpCookie a, HttpCookie b) {
                return a.getName().compareTo(b.getName());
            } 
        }); 
        return result;
    } 
 
    private Map<String,List<String>> get(MockWebServer server, String path) throws Exception {
        URLConnection connection = server.getUrl(path).openConnection();
        Map<String, List<String>> headers = connection.getHeaderFields();
        connection.getInputStream().close();
        return headers;
    } 
 
    private Map<String, List<String>> cookieHeaders(String... headers) {
        return Collections.singletonMap("Set-Cookie", Arrays.asList(headers));
4
CodeRank

Related Java 8 HttpCookie Questions & Answers:

See Code Examples for Java 8 HttpCookie Methods: