下面列出了怎么用java.net.CacheRequest的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
@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);
}
@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);
}
@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);
}
@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);
}
@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);
}
@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);
}
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;
}
}
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;
}
}
@Override
public CacheRequest put (URI uri,
URLConnection conn)
throws IOException
{
URL url = uri.toURL();
service.loadResource(url, null, service.getDefaultProgressWindow());
return null;
}
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;
}
}
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;
}
}
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;
}
}
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);
}
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;
}
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
long length) throws IOException {
super(is, httpEngine, cacheRequest);
bytesRemaining = length;
if (bytesRemaining == 0) {
endOfInput();
}
}
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;
}
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;
}
}
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);
}
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;
}
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;
}
}
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);
}
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
long length) throws IOException {
super(is, httpEngine, cacheRequest);
bytesRemaining = length;
if (bytesRemaining == 0) {
endOfInput();
}
}
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;
}
}
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine, int length) throws IOException {
super(is, httpEngine, cacheRequest);
bytesRemaining = length;
if (bytesRemaining == 0) {
endOfInput();
}
}
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;
}
}
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);
}
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
long length) throws IOException {
super(is, httpEngine, cacheRequest);
bytesRemaining = length;
if (bytesRemaining == 0) {
endOfInput();
}
}
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;
}
public FixedLengthInputStream(InputStream is, CacheRequest cacheRequest, HttpEngine httpEngine,
long length) throws IOException {
super(is, httpEngine, cacheRequest);
bytesRemaining = length;
if (bytesRemaining == 0) {
endOfInput();
}
}