import com.squareup.okhttp.Request; //导入方法依赖的package包/类
private HttpEngine getResponse() throws IOException {
initHttpEngine();
if (this.httpEngine.hasResponse()) {
return this.httpEngine;
}
while (true) {
if (execute(true)) {
Response response = this.httpEngine.getResponse();
Request followUp = this.httpEngine.followUpRequest();
if (followUp == null) {
this.httpEngine.releaseStreamAllocation();
return this.httpEngine;
}
int i = this.followUpCount + 1;
this.followUpCount = i;
if (i > 20) {
throw new ProtocolException("Too many follow-up requests: " + this
.followUpCount);
}
this.url = followUp.url();
this.requestHeaders = followUp.headers().newBuilder();
Sink requestBody = this.httpEngine.getRequestBody();
if (!followUp.method().equals(this.method)) {
requestBody = null;
}
if (requestBody == null || (requestBody instanceof RetryableSink)) {
StreamAllocation streamAllocation = this.httpEngine.close();
if (!this.httpEngine.sameConnection(followUp.httpUrl())) {
streamAllocation.release();
streamAllocation = null;
}
this.httpEngine = newHttpEngine(followUp.method(), streamAllocation,
(RetryableSink) requestBody, response);
} else {
throw new HttpRetryException("Cannot retry streamed HTTP body", this
.responseCode);
}
}
}
}