类com.squareup.okhttp.internal.AbstractOutputStream源码实例Demo

下面列出了怎么用com.squareup.okhttp.internal.AbstractOutputStream的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: L.TileLayer.Cordova   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码2 项目: IoTgo_Android_App   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码3 项目: android-discourse   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut, InputStream responseBodyIn) {
    if (streamCanceled) {
        return false;
    }

    // We cannot reuse sockets that have incomplete output.
    if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
        return false;
    }

    // If the request specified that the connection shouldn't be reused, don't reuse it.
    if (httpEngine.requestHeaders.hasConnectionClose()) {
        return false;
    }

    // If the response specified that the connection shouldn't be reused, don't reuse it.
    if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
        return false;
    }

    if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
        return false;
    }

    if (responseBodyIn != null) {
        return discardStream(httpEngine, responseBodyIn);
    }

    return true;
}
 
源代码4 项目: bluemix-parking-meter   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码5 项目: reader   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码6 项目: reader   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码7 项目: cordova-amazon-fireos   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码8 项目: phonegapbootcampsite   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码9 项目: CordovaYoutubeVideoPlayer   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
@Override public final OutputStream getOutputStream() throws IOException {
  connect();

  OutputStream out = httpEngine.getRequestBody();
  if (out == null) {
    throw new ProtocolException("method does not support a request body: " + method);
  } else if (httpEngine.hasResponse()) {
    throw new ProtocolException("cannot write request body after response has been read");
  }

  if (faultRecoveringRequestBody == null) {
    faultRecoveringRequestBody = new FaultRecoveringOutputStream(MAX_REPLAY_BUFFER_LENGTH, out) {
      @Override protected OutputStream replacementStream(IOException e) throws IOException {
        if (httpEngine.getRequestBody() instanceof AbstractOutputStream
            && ((AbstractOutputStream) httpEngine.getRequestBody()).isClosed()) {
          return null; // Don't recover once the underlying stream has been closed.
        }
        if (handleFailure(e)) {
          return httpEngine.getRequestBody();
        }
        return null; // This is a permanent failure.
      }
    };
  }

  return faultRecoveringRequestBody;
}
 
源代码11 项目: cordova-android-chromeview   文件: HttpTransport.java
public boolean makeReusable(boolean streamCancelled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCancelled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码12 项目: wildfly-samples   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
@Override public final OutputStream getOutputStream() throws IOException {
  connect();

  OutputStream out = httpEngine.getRequestBody();
  if (out == null) {
    throw new ProtocolException("method does not support a request body: " + method);
  } else if (httpEngine.hasResponse()) {
    throw new ProtocolException("cannot write request body after response has been read");
  }

  if (faultRecoveringRequestBody == null) {
    faultRecoveringRequestBody = new FaultRecoveringOutputStream(MAX_REPLAY_BUFFER_LENGTH, out) {
      @Override protected OutputStream replacementStream(IOException e) throws IOException {
        if (httpEngine.getRequestBody() instanceof AbstractOutputStream
            && ((AbstractOutputStream) httpEngine.getRequestBody()).isClosed()) {
          return null; // Don't recover once the underlying stream has been closed.
        }
        if (handleFailure(e)) {
          return httpEngine.getRequestBody();
        }
        return null; // This is a permanent failure.
      }
    };
  }

  return faultRecoveringRequestBody;
}
 
public boolean makeReusable(boolean streamCancelled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCancelled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
源代码15 项目: crosswalk-cordova-android   文件: HttpTransport.java
public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
    InputStream responseBodyIn) {
  if (streamCanceled) {
    return false;
  }

  // We cannot reuse sockets that have incomplete output.
  if (requestBodyOut != null && !((AbstractOutputStream) requestBodyOut).isClosed()) {
    return false;
  }

  // If the request specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.requestHeaders.hasConnectionClose()) {
    return false;
  }

  // If the response specified that the connection shouldn't be reused, don't reuse it.
  if (httpEngine.responseHeaders != null && httpEngine.responseHeaders.hasConnectionClose()) {
    return false;
  }

  if (responseBodyIn instanceof UnknownLengthHttpInputStream) {
    return false;
  }

  if (responseBodyIn != null) {
    return discardStream(httpEngine, responseBodyIn);
  }

  return true;
}
 
 类所在包
 类方法
 同包方法