本文整理匯總了Java中com.squareup.okhttp.Request.url方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.url方法的具體用法?Java Request.url怎麽用?Java Request.url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.squareup.okhttp.Request
的用法示例。
在下文中一共展示了Request.url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onOkHttpNew
import com.squareup.okhttp.Request; //導入方法依賴的package包/類
@Around("call(* com.squareup.okhttp.OkHttpClient+.newCall(..))")
public Object onOkHttpNew(ProceedingJoinPoint joinPoint) throws Throwable {
if (!Configuration.httpMonitorEnable || joinPoint.getArgs().length != 1) {
return joinPoint.proceed();
}
Object[] args = joinPoint.getArgs();
Request request = (Request) args[0];
//url
URL url = request.url();
if (GlobalConfig.isExcludeHost(url.getHost())) {
return joinPoint.proceed();
}
RespBean bean = new RespBean();
bean.setUrl(url.toString());
bean.setStartTimestamp(System.currentTimeMillis());
startTimeStamp.add(bean);
return joinPoint.proceed();
}
示例2: getResponse
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);
}
}
}
}