本文整理匯總了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())));
}