Lines Matching defs:connection

318         HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
319 assertNull(connection.getErrorStream());
325 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
326 assertEquals("A", readAscii(connection.getErrorStream(), Integer.MAX_VALUE));
330 // recycled connection doesn't get the unread tail of the first request's response.
409 .setBody("This connection won't pool properly")
411 server.enqueue(new MockResponse().setBody("This comes after a busted connection"));
414 assertContent("This connection won't pool properly", server.getUrl("/a").openConnection());
416 assertContent("This comes after a busted connection", server.getUrl("/b").openConnection());
417 // sequence number 0 means the HTTP socket connection was not reused
422 // This test causes MockWebServer to log a "connection failed" stack trace
433 server.enqueue(new MockResponse().setBody("This comes after a busted connection"));
438 assertContent("This comes after a busted connection", server.getUrl("/b").openConnection());
530 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/foo").openConnection();
531 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
533 assertContent("this response comes via HTTPS", connection);
549 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
550 connection.setSSLSocketFactory(clientSocketFactory);
551 assertContent("this response comes via HTTPS", connection);
553 connection = (HttpsURLConnection) server.getUrl("/").openConnection();
554 connection.setSSLSocketFactory(clientSocketFactory);
555 assertContent("another response via HTTPS", connection);
571 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
572 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
573 assertContent("this response comes via HTTPS", connection);
575 connection = (HttpsURLConnection) server.getUrl("/").openConnection();
577 readAscii(connection.getInputStream(), Integer.MAX_VALUE);
578 fail("without an SSL socket factory, the connection should fail");
596 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/foo").openConnection();
597 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
599 connection.getInputStream();
655 HttpURLConnection connection = proxyConfig.connect(server, url);
656 assertContent("this response comes via a proxy", connection);
706 HttpsURLConnection connection = (HttpsURLConnection) proxyConfig.connect(server, url);
707 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
709 assertContent("this response comes via HTTPS", connection);
748 HttpsURLConnection connection = (HttpsURLConnection) proxyConfig.connect(server, url);
749 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
750 connection.setHostnameVerifier(hostnameVerifier);
752 assertContent("this response comes via a secure proxy", connection);
789 HttpsURLConnection connection = (HttpsURLConnection) proxyConfig.connect(server, url);
790 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
791 connection.setHostnameVerifier(new RecordingHostnameVerifier());
792 assertContent("response", connection);
871 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
872 assertEquals(etagValue, connection.getHeaderField("Etag"));
873 assertContent(body, connection);
874 connection.disconnect();
920 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
921 assertEquals(etagValue1, connection.getHeaderField("Etag"));
922 assertContent(body1, connection);
923 connection.disconnect();
955 HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(
957 connection.addRequestProperty("Private", "Secret");
958 connection.addRequestProperty("Proxy-Authorization", "bar");
959 connection.addRequestProperty("User-Agent", "baz");
960 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
961 connection.setHostnameVerifier(hostnameVerifier);
962 assertContent("encrypted response from the origin server", connection);
990 HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(
992 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
993 connection.setHostnameVerifier(new RecordingHostnameVerifier());
994 assertContent("A", connection);
1022 HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(
1024 connection.setRequestProperty("Connection", "close");
1025 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
1026 connection.setHostnameVerifier(new RecordingHostnameVerifier());
1028 assertContent("this response comes via a proxy", connection);
1037 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1038 InputStream in = connection.getInputStream();
1040 connection.disconnect();
1046 fail("Expected a connection closed exception");
1055 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1056 connection.disconnect();
1058 assertContent("A", connection);
1059 assertEquals(200, connection.getResponseCode());
1068 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1070 assertEquals(200, connection.getResponseCode());
1072 connection.disconnect();
1162 URLConnection connection = server.getUrl("/").openConnection();
1164 readAscii(connection.getInputStream(), Integer.MAX_VALUE);
1178 URLConnection connection = server.getUrl("/").openConnection();
1180 readAscii(connection.getInputStream(), Integer.MAX_VALUE);
1197 URLConnection connection = server.getUrl("/").openConnection();
1198 assertEquals("ABCABCABC", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1199 assertNull(connection.getContentEncoding());
1200 assertEquals(-1, connection.getContentLength());
1214 URLConnection connection = server.getUrl("/").openConnection();
1215 connection.addRequestProperty("Accept-Encoding", "gzip");
1216 InputStream gunzippedIn = new GZIPInputStream(connection.getInputStream());
1218 assertEquals(bodyBytes.length, connection.getContentLength());
1222 assertEquals("gzip", connection.getContentEncoding());
1239 URLConnection connection = server.getUrl("/").openConnection();
1240 connection.addRequestProperty("Accept-Encoding", "custom");
1241 assertEquals("ABCDE", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1263 URLConnection connection = server.getUrl("/").openConnection();
1264 connection.addRequestProperty("Accept-Encoding", "gzip");
1265 InputStream gunzippedIn = new GZIPInputStream(connection.getInputStream());
1269 connection = server.getUrl("/").openConnection();
1270 assertEquals("two (identity)", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1348 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1349 connection.setDoOutput(true);
1352 connection.setFixedLengthStreamingMode(requestBody.length);
1354 connection.setChunkedStreamingMode(0);
1356 OutputStream outputStream = connection.getOutputStream();
1360 connection.getInputStream();
1383 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1384 connection.setRequestMethod(requestMethod);
1385 assertEquals(requestMethod, connection.getRequestMethod());
1399 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1401 connection.setRequestMethod(requestMethod);
1409 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1411 connection.setFixedLengthStreamingMode(-2);
1419 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1420 connection.setChunkedStreamingMode(-2);
1426 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1427 assertEquals("A", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1429 connection.setFixedLengthStreamingMode(1);
1438 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1439 assertEquals("A", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1441 connection.setChunkedStreamingMode(1);
1449 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1450 connection.setChunkedStreamingMode(1);
1452 connection.setFixedLengthStreamingMode(1);
1460 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1461 connection.setFixedLengthStreamingMode(1);
1463 connection.setChunkedStreamingMode(1);
1487 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
1488 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
1489 connection.setDoOutput(true);
1492 connection.setFixedLengthStreamingMode(requestBody.length);
1494 connection.setChunkedStreamingMode(0);
1496 OutputStream outputStream = connection.getOutputStream();
1499 assertEquals("Success!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1529 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1530 connection.setDoOutput(true);
1532 OutputStream outputStream = connection.getOutputStream();
1535 assertEquals("Successful auth!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1566 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1567 assertEquals("Successful auth!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1604 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1605 assertEquals("Successful auth!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1627 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1628 assertEquals("Successful auth!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1649 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1650 assertEquals("Successful auth!", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1679 URLConnection connection = server.getUrl("/").openConnection();
1681 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1688 assertEquals("Expected connection reuse", 1, retry.getSequenceNumber());
1702 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
1703 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
1705 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1711 assertEquals("Expected connection reuse", 1, retry.getSequenceNumber());
1723 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
1724 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
1726 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1736 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1738 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1753 URLConnection connection = server.getUrl("/").openConnection();
1755 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1756 assertEquals(server2.getUrl("/"), connection.getURL());
1758 // make sure the first server was careful to recycle the connection
1767 assertEquals("Expected connection reuse", 1, third.getSequenceNumber());
1777 // existing keep-alive connection.
1825 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
1826 assertEquals("Target", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1868 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
1869 assertFalse(connection.getInstanceFollowRedirects());
1906 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/page1").openConnection();
1907 connection.setDoOutput(true);
1909 OutputStream outputStream = connection.getOutputStream();
1912 assertEquals("Page 2", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1913 assertTrue(connection.getDoOutput());
1931 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/foo").openConnection();
1934 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
1979 * connection attempt. If a hostname resolves to multiple IPs HttpURLConnection will wait the
2039 * connection after a response has been sent. This causes the client to
2078 server.enqueue(new MockResponse()); // server doesn't honor the connection: close header!
2090 assertEquals("When connection: close is used, each request should get its own connection",
2106 assertEquals("When connection: close is used, each request should get its own connection",
2119 URLConnection connection = server.getUrl("/").openConnection();
2121 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2124 assertEquals("When connection: close is used, each request should get its own connection",
2134 URLConnection connection = server.getUrl("/").openConnection();
2136 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2143 URLConnection connection = server.getUrl("/").openConnection();
2144 InputStream in = connection.getInputStream();
2171 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2172 connection.setDoOutput(true);
2176 connection.setChunkedStreamingMode(0);
2178 connection.setFixedLengthStreamingMode(upload.length);
2181 OutputStream out = connection.getOutputStream();
2183 assertEquals("abc", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2197 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2199 connection.getInputStream();
2205 connection.getInputStream();
2216 URLConnection connection = server.getUrl("").openConnection();
2218 connection.setReadTimeout(24 * 3600 * 1000);
2219 InputStream input = connection.getInputStream();
2223 connection = server.getUrl("").openConnection();
2226 connection.setReadTimeout(100);
2227 connection.getInputStream();
2385 @Override public CacheRequest put(URI uri, URLConnection connection)
2397 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
2398 connection.getResponseCode();
2476 @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
2491 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2492 InputStream in = connection.getInputStream();
2510 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2511 InputStream in = connection.getInputStream();
2520 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2521 InputStream in = (InputStream) connection.getContent();
2528 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2530 connection.getContent(null);
2535 connection.getContent(new Class[] { null });
2539 assertNull(connection.getContent(new Class[] { getClass() }));
2540 connection.disconnect();
2546 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2548 connection.getOutputStream();
2557 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2558 connection.setDoOutput(true);
2560 connection.getInputStream();
2561 connection.getOutputStream();
2570 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2571 connection.connect();
2573 connection.setDoOutput(true);
2578 connection.setDoInput(true);
2582 connection.disconnect();
2591 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2592 connection.connect();
2594 assertEquals(1385551560000L, connection.getLastModified());
2595 assertEquals(1385551560000L, connection.getHeaderFieldDate("Last-Modified", -1));
2601 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2602 connection.setDoOutput(true);
2603 OutputStream out = connection.getOutputStream();
2606 assertEquals("A", readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2614 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2615 assertEquals(3, connection.getContentLength());
2616 connection.disconnect();
2624 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2625 assertEquals("text/plain", connection.getContentType());
2626 connection.disconnect();
2634 HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
2635 assertEquals("identity", connection.getContentEncoding());
2636 connection.disconnect();
2668 URLConnection connection = server.getUrl("/").openConnection();
2669 InputStream in = connection.getInputStream();
2728 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
2735 connection.setSSLSocketFactory(clientSocketFactory);
2737 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2739 // Confirm the server accepted a single connection.
2775 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
2781 connection.setSSLSocketFactory(clientSocketFactory);
2783 readAscii(connection.getInputStream(), Integer.MAX_VALUE));
2785 // Confirm the server accepted a single connection.
2822 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
2823 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
2824 assertNotNull(connection.getHostnameVerifier());
2826 connection.getLocalCertificates();
2831 connection.getServerCertificates();
2836 connection.getCipherSuite();
2841 connection.getPeerPrincipal();
2857 HttpsURLConnection connection = (HttpsURLConnection) server.getUrl("/").openConnection();
2858 connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
2859 connection.connect();
2861 assertNotNull(connection.getHostnameVerifier());
2862 assertNull(connection.getLocalCertificates());
2863 assertNotNull(connection.getServerCertificates());
2864 assertNotNull(connection.getCipherSuite());
2865 assertNotNull(connection.getPeerPrincipal());
2867 connection.disconnect();
2898 // We expect the connection to fail with a cert validation exception because we're
2925 private void assertContent(String expected, URLConnection connection, int limit)
2927 connection.connect();
2928 assertEquals(expected, readAscii(connection.getInputStream(), limit));
2929 ((HttpURLConnection) connection).disconnect();
2932 private void assertContent(String expected, URLConnection connection) throws IOException {
2933 assertContent(expected, connection, Integer.MAX_VALUE);
3474 * The cipher suite used during TLS connection fallback to indicate a fallback.