本文整理汇总了Java中com.squareup.okhttp.Response.headers方法的典型用法代码示例。如果您正苦于以下问题:Java Response.headers方法的具体用法?Java Response.headers怎么用?Java Response.headers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.okhttp.Response
的用法示例。
在下文中一共展示了Response.headers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import com.squareup.okhttp.Response; //导入方法依赖的package包/类
public CacheStrategy$Factory(long nowMillis, Request request, Response cacheResponse) {
this.nowMillis = nowMillis;
this.request = request;
this.cacheResponse = cacheResponse;
if (cacheResponse != null) {
Headers headers = cacheResponse.headers();
int size = headers.size();
for (int i = 0; i < size; i++) {
String fieldName = headers.name(i);
String value = headers.value(i);
if ("Date".equalsIgnoreCase(fieldName)) {
this.servedDate = HttpDate.parse(value);
this.servedDateString = value;
} else if ("Expires".equalsIgnoreCase(fieldName)) {
this.expires = HttpDate.parse(value);
} else if ("Last-Modified".equalsIgnoreCase(fieldName)) {
this.lastModified = HttpDate.parse(value);
this.lastModifiedString = value;
} else if ("ETag".equalsIgnoreCase(fieldName)) {
this.etag = value;
} else if ("Age".equalsIgnoreCase(fieldName)) {
this.ageSeconds = HeaderParser.parseSeconds(value, -1);
} else if (OkHeaders.SENT_MILLIS.equalsIgnoreCase(fieldName)) {
this.sentRequestMillis = Long.parseLong(value);
} else if (OkHeaders.RECEIVED_MILLIS.equalsIgnoreCase(fieldName)) {
this.receivedResponseMillis = Long.parseLong(value);
}
}
}
}
示例2: openResponseBody
import com.squareup.okhttp.Response; //导入方法依赖的package包/类
public ResponseBody openResponseBody(Response response) throws IOException {
return new RealResponseBody(response.headers(), Okio.buffer(getTransferStream(response)));
}
示例3: openResponseBody
import com.squareup.okhttp.Response; //导入方法依赖的package包/类
public ResponseBody openResponseBody(Response response) throws IOException {
return new RealResponseBody(response.headers(), Okio.buffer(new StreamFinishingSource(this.stream.getSource())));
}