java request 方法_Java Request.url方法代码示例

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);

}

}

}

}


版权声明:本文为weixin_35660038原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。