java.net.CacheRequest Java Examples

The following examples show how to use java.net.CacheRequest. 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: HttpTransport.java    From reader with MIT License 6 votes vote down vote up
@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);
}
 
Example #2
Source File: HttpTransport.java    From L.TileLayer.Cordova with MIT License 6 votes vote down vote up
@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);
}
 
Example #3
Source File: HttpTransport.java    From reader with MIT License 6 votes vote down vote up
@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);
}
 
Example #4
Source File: HttpTransport.java    From bluemix-parking-meter with MIT License 6 votes vote down vote up
@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);
}
 
Example #5
Source File: HttpTransport.java    From phonegapbootcampsite with MIT License 6 votes vote down vote up
@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);
}
 
Example #6
Source File: HttpTransport.java    From IoTgo_Android_App with MIT License 6 votes vote down vote up
@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);
}
 
Example #7
Source File: HttpTransport.java    From cordova-amazon-fireos with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #8
Source File: HttpURLConnection.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #9
Source File: HttpURLConnection.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #10
Source File: JnlpResponseCache.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public CacheRequest put (URI           uri,
                         URLConnection conn)
    throws IOException
{
    URL url = uri.toURL();
    service.loadResource(url, null, service.getDefaultProgressWindow());

    return null;
}
 
Example #11
Source File: TestCache.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example #12
Source File: AbstractHttpInputStream.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #13
Source File: HttpURLConnection.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #14
Source File: HttpURLConnection.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #15
Source File: HttpURLConnection.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #16
Source File: HttpTransport.java    From reader with MIT License 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
 
Example #17
Source File: AbstractHttpInputStream.java    From cordova-amazon-fireos with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: TestCache.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example #19
Source File: HttpURLConnection.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #20
Source File: TestCache.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example #21
Source File: HttpTransport.java    From L.TileLayer.Cordova with MIT License 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
 
Example #22
Source File: HttpURLConnection.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #23
Source File: HttpTransport.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine, int length) throws IOException {
    super(is, httpEngine, cacheRequest);
    bytesRemaining = length;
    if (bytesRemaining == 0) {
        endOfInput();
    }
}
 
Example #24
Source File: HttpURLConnection.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #25
Source File: TestCache.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example #26
Source File: HttpTransport.java    From cordova-amazon-fireos with Apache License 2.0 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
 
Example #27
Source File: AbstractHttpInputStream.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
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;
}
 
Example #28
Source File: HttpTransport.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}
 
Example #29
Source File: AbstractHttpInputStream.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #30
Source File: HttpTransport.java    From reader with MIT License 5 votes vote down vote up
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
    long length) throws IOException {
  super(is, httpEngine, cacheRequest);
  bytesRemaining = length;
  if (bytesRemaining == 0) {
    endOfInput();
  }
}