use of com.squareup.okhttp.internal.AbstractOutputStream in project cordova-android-chromeview by thedracle.
the class HttpURLConnectionImpl method getOutputStream.
@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()) {
// Don't recover once the underlying stream has been closed.
return null;
}
if (handleFailure(e)) {
return httpEngine.getRequestBody();
}
// This is a permanent failure.
return null;
}
};
}
return faultRecoveringRequestBody;
}
use of com.squareup.okhttp.internal.AbstractOutputStream in project phonegap-facebook-plugin by Wizcorp.
the class HttpURLConnectionImpl method getOutputStream.
@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()) {
// Don't recover once the underlying stream has been closed.
return null;
}
if (handleFailure(e)) {
return httpEngine.getRequestBody();
}
// This is a permanent failure.
return null;
}
};
}
return faultRecoveringRequestBody;
}
Aggregations