Java Code Examples for java.net.CookiePolicy#ACCEPT_ALL
The following examples show how to use
java.net.CookiePolicy#ACCEPT_ALL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CookieHttpClientTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
CookieHttpClientTest() throws Exception { /* start the server */ ss = new ServerSocket(0); (new Thread(this)).start(); URL url = new URL("http://localhost:" + ss.getLocalPort() +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 2
Source File: CookieHttpClientTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
CookieHttpClientTest() throws Exception { /* start the server */ ss = new ServerSocket(0); (new Thread(this)).start(); URL url = new URL("http://localhost:" + ss.getLocalPort() +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 3
Source File: HttpOnly.java From hottub with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 4
Source File: CookieHttpClientTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
CookieHttpClientTest() throws Exception { /* start the server */ ss = new ServerSocket(0); (new Thread(this)).start(); URL url = new URL("http://localhost:" + ss.getLocalPort() +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 5
Source File: HttpOnly.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 6
Source File: CookieHttpsClientTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 7
Source File: HttpOnly.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 8
Source File: HttpOnly.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 9
Source File: RawHttpCliClient.java From rawhttp with Apache License 2.0 | 5 votes |
private static CookieHandler cookieManagerFor(@Nullable File cookieJar) { CookieStore cookieStore; try { cookieStore = cookieJar == null ? null : new FileCookieJar(cookieJar); } catch (IOException e) { throw new RuntimeException(e); } return new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL); }
Example 10
Source File: CookieHttpsClientTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 11
Source File: HttpOnly.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 12
Source File: CookieHttpsClientTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 13
Source File: CookieHttpsClientTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 14
Source File: SomePreferences.java From something.apk with MIT License | 5 votes |
public synchronized static void init(Context context){ cookieStore = new PersistentCookieStore(context.getApplicationContext()); cookieManager = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL); CookieManager.setDefault(cookieManager); preferenceStore = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); updatePreferences(preferenceStore); preferenceStore.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { updatePreferences(sharedPreferences); } }); }
Example 15
Source File: CookieHttpsClientTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 16
Source File: CookieHttpsClientTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void doClientSide() throws Exception { // Wait for server to get started. while (!serverReady) { Thread.sleep(50); } HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; }}); URL url = new URL("https://localhost:" + serverPort +"/"); // Run without a CookieHandler first InputStream in = url.openConnection().getInputStream(); while (in.read() != -1); // read response body so connection can be reused // Set a CookeHandler and retest using the HttpClient from the KAC CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); in = url.openConnection().getInputStream(); while (in.read() != -1); if (manager.getCookieStore().getCookies().isEmpty()) { throw new RuntimeException("Failed: No cookies in the cookie Handler."); } }
Example 17
Source File: HttpOnly.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 18
Source File: HttpOnly.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void populateCookieStore(URI uri) throws IOException { CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); Map<String,List<String>> header = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); header.put("Set-Cookie", values); cm.put(uri, header); }
Example 19
Source File: URLite.java From httplite with Apache License 2.0 | 4 votes |
public Builder setCookieStore(CookieStore cookieStore){ cookieHandler = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL); return this; }
Example 20
Source File: Ok3Lite.java From httplite with Apache License 2.0 | 4 votes |
public Builder setCookieStore(CookieStore cookieStore){ if(cookieStore!=null) this.cookieJar = new CookieJarImpl(new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL)); return this; }