Java 类java.net.CacheRequest 实例源码

项目:LoRaWAN-Smart-Parking    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:LoRaWAN-Smart-Parking    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:smart-mirror-app    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:cordova-plugin-background-mode    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:multirotorstuff-vtx-calc    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:hackmxdf-2015    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:pubnub-rpi-smart-parking    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:posjs2    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:IoTgo_Android_App    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:gwt-material-phonegap    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:CanDoVS2015    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:krakn    文件:HttpTransport.java   
@Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
  if (!httpEngine.hasResponseBody()) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine, 0);
  }

  if (httpEngine.responseHeaders.isChunked()) {
    return new ChunkedInputStream(socketIn, cacheRequest, this);
  }

  if (httpEngine.responseHeaders.getContentLength() != -1) {
    return new FixedLengthInputStream(socketIn, cacheRequest, httpEngine,
        httpEngine.responseHeaders.getContentLength());
  }

  // Wrap the input stream from the connection (rather than just returning
  // "socketIn" directly here), so that we can control its use after the
  // reference escapes.
  return new UnknownLengthHttpInputStream(socketIn, cacheRequest, httpEngine);
}
项目:GitHub    文件:AndroidShimResponseCache.java   
@Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
  Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection);
  if (okResponse == null) {
    // The URLConnection is not cacheable or could not be converted. Stop.
    return null;
  }
  okhttp3.internal.cache.CacheRequest okCacheRequest =
      delegate.internalCache.put(okResponse);
  if (okCacheRequest == null) {
    return null;
  }
  return JavaApiConverter.createJavaCacheRequest(okCacheRequest);
}
项目:GitHub    文件:CacheAdapterTest.java   
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      try {
        assertTrue(connection instanceof HttpsURLConnection);
        assertEquals(toUri(serverUrl), uri);
        assertEquals(serverUrl, connection.getURL());

        HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
        HttpsURLConnection realHttpsUrlConnection =
            (HttpsURLConnection) CacheAdapterTest.this.connection;
        assertEquals(realHttpsUrlConnection.getCipherSuite(),
            cacheHttpsUrlConnection.getCipherSuite());
        assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
            cacheHttpsUrlConnection.getPeerPrincipal());
        assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
            cacheHttpsUrlConnection.getLocalCertificates());
        assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
            cacheHttpsUrlConnection.getServerCertificates());
        assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
            cacheHttpsUrlConnection.getLocalPrincipal());
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
项目:GitHub    文件:AndroidShimResponseCache.java   
@Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
  Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection);
  if (okResponse == null) {
    // The URLConnection is not cacheable or could not be converted. Stop.
    return null;
  }
  okhttp3.internal.cache.CacheRequest okCacheRequest =
      delegate.internalCache.put(okResponse);
  if (okCacheRequest == null) {
    return null;
  }
  return JavaApiConverter.createJavaCacheRequest(okCacheRequest);
}
项目:GitHub    文件:CacheAdapterTest.java   
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      try {
        assertTrue(connection instanceof HttpsURLConnection);
        assertEquals(toUri(serverUrl), uri);
        assertEquals(serverUrl, connection.getURL());

        HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
        HttpsURLConnection realHttpsUrlConnection =
            (HttpsURLConnection) CacheAdapterTest.this.connection;
        assertEquals(realHttpsUrlConnection.getCipherSuite(),
            cacheHttpsUrlConnection.getCipherSuite());
        assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
            cacheHttpsUrlConnection.getPeerPrincipal());
        assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
            cacheHttpsUrlConnection.getLocalCertificates());
        assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
            cacheHttpsUrlConnection.getServerCertificates());
        assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
            cacheHttpsUrlConnection.getLocalPrincipal());
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
项目:OpenJSharp    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:LoRaWAN-Smart-Parking    文件:AbstractHttpInputStream.java   
AbstractHttpInputStream(InputStream in, HttpEngine httpEngine, CacheRequest cacheRequest)
    throws IOException {
  this.in = in;
  this.httpEngine = httpEngine;

  OutputStream cacheBody = cacheRequest != null ? cacheRequest.getBody() : null;

  // some apps return a null body; for compatibility we treat that like a null cache request
  if (cacheBody == null) {
    cacheRequest = null;
  }

  this.cacheBody = cacheBody;
  this.cacheRequest = cacheRequest;
}
项目:LoRaWAN-Smart-Parking    文件:HttpTransport.java   
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
项目:LoRaWAN-Smart-Parking    文件:AbstractHttpInputStream.java   
AbstractHttpInputStream(InputStream in, HttpEngine httpEngine, CacheRequest cacheRequest)
    throws IOException {
  this.in = in;
  this.httpEngine = httpEngine;

  OutputStream cacheBody = cacheRequest != null ? cacheRequest.getBody() : null;

  // some apps return a null body; for compatibility we treat that like a null cache request
  if (cacheBody == null) {
    cacheRequest = null;
  }

  this.cacheBody = cacheBody;
  this.cacheRequest = cacheRequest;
}
项目:LoRaWAN-Smart-Parking    文件:HttpTransport.java   
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
项目:jdk8u-jdk    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:jdk8u-jdk    文件:TestCache.java   
public synchronized CacheRequest put(URI uri, URLConnection conn)
throws IOException {
    System.out.println("put: " + uri);
    Thread.currentThread().dumpStack();
    URL url = uri.toURL();
    return new DeployCacheRequest(url, conn);

}
项目:openjdk-jdk10    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:openjdk-jdk10    文件:TestCache.java   
public synchronized CacheRequest put(URI uri, URLConnection conn)
throws IOException {
    System.out.println("put: " + uri);
    Thread.currentThread().dumpStack();
    URL url = uri.toURL();
    return new DeployCacheRequest(url, conn);

}
项目:openjdk9    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:openjdk9    文件:TestCache.java   
public synchronized CacheRequest put(URI uri, URLConnection conn)
throws IOException {
    System.out.println("put: " + uri);
    Thread.currentThread().dumpStack();
    URL url = uri.toURL();
    return new DeployCacheRequest(url, conn);

}
项目:PriorityOkHttp    文件:AndroidShimResponseCache.java   
@Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
  Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection);
  if (okResponse == null) {
    // The URLConnection is not cacheable or could not be converted. Stop.
    return null;
  }
  okhttp3.internal.http.CacheRequest okCacheRequest =
      delegate.internalCache.put(okResponse);
  if (okCacheRequest == null) {
    return null;
  }
  return JavaApiConverter.createJavaCacheRequest(okCacheRequest);
}
项目:PriorityOkHttp    文件:CacheAdapterTest.java   
@Test public void put_httpGet() throws Exception {
  final String statusLine = "HTTP/1.1 200 Fantastic";
  final byte[] response = "ResponseString".getBytes(StandardCharsets.UTF_8);
  final URL serverUrl = configureServer(
      new MockResponse()
          .setStatus(statusLine)
          .addHeader("A", "c")
          .setBody(new Buffer().write(response)));

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      assertTrue(connection instanceof HttpURLConnection);
      assertFalse(connection instanceof HttpsURLConnection);

      assertEquals(response.length, connection.getContentLength());

      HttpURLConnection httpUrlConnection = (HttpURLConnection) connection;
      assertEquals("GET", httpUrlConnection.getRequestMethod());
      assertTrue(httpUrlConnection.getDoInput());
      assertFalse(httpUrlConnection.getDoOutput());

      assertEquals("Fantastic", httpUrlConnection.getResponseMessage());
      assertEquals(toUri(serverUrl), uri);
      assertEquals(serverUrl, connection.getURL());
      assertEquals("value", connection.getRequestProperty("key"));

      // Check retrieval by string key.
      assertEquals(statusLine, httpUrlConnection.getHeaderField(null));
      assertEquals("c", httpUrlConnection.getHeaderField("A"));
      // The RI and OkHttp supports case-insensitive matching for this method.
      assertEquals("c", httpUrlConnection.getHeaderField("a"));
      return null;
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key", "value");
  executeGet(connection);
}
项目:PriorityOkHttp    文件:CacheAdapterTest.java   
@Test public void put_httpPost() throws Exception {
  final String statusLine = "HTTP/1.1 200 Fantastic";
  final URL serverUrl = configureServer(
      new MockResponse()
          .setStatus(statusLine)
          .addHeader("A", "c"));

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      assertTrue(connection instanceof HttpURLConnection);
      assertFalse(connection instanceof HttpsURLConnection);

      assertEquals(0, connection.getContentLength());

      HttpURLConnection httpUrlConnection = (HttpURLConnection) connection;
      assertEquals("POST", httpUrlConnection.getRequestMethod());
      assertTrue(httpUrlConnection.getDoInput());
      assertTrue(httpUrlConnection.getDoOutput());

      assertEquals("Fantastic", httpUrlConnection.getResponseMessage());
      assertEquals(toUri(serverUrl), uri);
      assertEquals(serverUrl, connection.getURL());
      assertEquals("value", connection.getRequestProperty("key"));

      // Check retrieval by string key.
      assertEquals(statusLine, httpUrlConnection.getHeaderField(null));
      assertEquals("c", httpUrlConnection.getHeaderField("A"));
      // The RI and OkHttp supports case-insensitive matching for this method.
      assertEquals("c", httpUrlConnection.getHeaderField("a"));
      return null;
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);

  executePost(connection);
}
项目:PriorityOkHttp    文件:CacheAdapterTest.java   
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      assertTrue(connection instanceof HttpsURLConnection);
      assertEquals(toUri(serverUrl), uri);
      assertEquals(serverUrl, connection.getURL());

      HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
      HttpsURLConnection realHttpsUrlConnection =
          (HttpsURLConnection) CacheAdapterTest.this.connection;
      assertEquals(realHttpsUrlConnection.getCipherSuite(),
          cacheHttpsUrlConnection.getCipherSuite());
      assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
          cacheHttpsUrlConnection.getPeerPrincipal());
      assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
          cacheHttpsUrlConnection.getLocalCertificates());
      assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
          cacheHttpsUrlConnection.getServerCertificates());
      assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
          cacheHttpsUrlConnection.getLocalPrincipal());
      return null;
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslContext.getSocketFactory())
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
项目:Okhttp    文件:AndroidShimResponseCache.java   
@Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
  Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection);
  if (okResponse == null) {
    // The URLConnection is not cacheable or could not be converted. Stop.
    return null;
  }
  okhttp3.internal.cache.CacheRequest okCacheRequest =
      delegate.internalCache.put(okResponse);
  if (okCacheRequest == null) {
    return null;
  }
  return JavaApiConverter.createJavaCacheRequest(okCacheRequest);
}
项目:Okhttp    文件:CacheAdapterTest.java   
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      try {
        assertTrue(connection instanceof HttpsURLConnection);
        assertEquals(toUri(serverUrl), uri);
        assertEquals(serverUrl, connection.getURL());

        HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
        HttpsURLConnection realHttpsUrlConnection =
            (HttpsURLConnection) CacheAdapterTest.this.connection;
        assertEquals(realHttpsUrlConnection.getCipherSuite(),
            cacheHttpsUrlConnection.getCipherSuite());
        assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
            cacheHttpsUrlConnection.getPeerPrincipal());
        assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
            cacheHttpsUrlConnection.getLocalCertificates());
        assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
            cacheHttpsUrlConnection.getServerCertificates());
        assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
            cacheHttpsUrlConnection.getLocalPrincipal());
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
项目:smart-mirror-app    文件:AbstractHttpInputStream.java   
AbstractHttpInputStream(InputStream in, HttpEngine httpEngine, CacheRequest cacheRequest)
    throws IOException {
  this.in = in;
  this.httpEngine = httpEngine;

  OutputStream cacheBody = cacheRequest != null ? cacheRequest.getBody() : null;

  // some apps return a null body; for compatibility we treat that like a null cache request
  if (cacheBody == null) {
    cacheRequest = null;
  }

  this.cacheBody = cacheBody;
  this.cacheRequest = cacheRequest;
}
项目:smart-mirror-app    文件:HttpTransport.java   
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
项目:jdk8u_jdk    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:jdk8u_jdk    文件:TestCache.java   
public synchronized CacheRequest put(URI uri, URLConnection conn)
throws IOException {
    System.out.println("put: " + uri);
    Thread.currentThread().dumpStack();
    URL url = uri.toURL();
    return new DeployCacheRequest(url, conn);

}
项目:lookaside_java-1.8.0-openjdk    文件:HttpURLConnection.java   
public HttpInputStream (InputStream is, CacheRequest cacheRequest) {
    super (is);
    this.cacheRequest = cacheRequest;
    try {
        this.outputStream = cacheRequest.getBody();
    } catch (IOException ioex) {
        this.cacheRequest.abort();
        this.cacheRequest = null;
        this.outputStream = null;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TestCache.java   
public synchronized CacheRequest put(URI uri, URLConnection conn)
throws IOException {
    System.out.println("put: " + uri);
    Thread.currentThread().dumpStack();
    URL url = uri.toURL();
    return new DeployCacheRequest(url, conn);

}
项目:cordova-plugin-background-mode    文件:AbstractHttpInputStream.java   
AbstractHttpInputStream(InputStream in, HttpEngine httpEngine, CacheRequest cacheRequest)
    throws IOException {
  this.in = in;
  this.httpEngine = httpEngine;

  OutputStream cacheBody = cacheRequest != null ? cacheRequest.getBody() : null;

  // some apps return a null body; for compatibility we treat that like a null cache request
  if (cacheBody == null) {
    cacheRequest = null;
  }

  this.cacheBody = cacheBody;
  this.cacheRequest = cacheRequest;
}