本文整理汇总了Java中com.squareup.okhttp.Request.header方法的典型用法代码示例。如果您正苦于以下问题:Java Request.header方法的具体用法?Java Request.header怎么用?Java Request.header使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.okhttp.Request
的用法示例。
在下文中一共展示了Request.header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: networkRequest
import com.squareup.okhttp.Request; //导入方法依赖的package包/类
private Request networkRequest(Request request) throws IOException {
Request.Builder result = request.newBuilder();
if (request.header("Host") == null) {
result.header("Host", Util.hostHeader(request.httpUrl()));
}
if (request.header("Connection") == null) {
result.header("Connection", "Keep-Alive");
}
if (request.header(AsyncHttpClient.HEADER_ACCEPT_ENCODING) == null) {
this.transparentGzip = true;
result.header(AsyncHttpClient.HEADER_ACCEPT_ENCODING, AsyncHttpClient.ENCODING_GZIP);
}
CookieHandler cookieHandler = this.client.getCookieHandler();
if (cookieHandler != null) {
OkHeaders.addCookies(result, cookieHandler.get(request.uri(), OkHeaders.toMultimap
(result.build().headers(), null)));
}
if (request.header(Network.USER_AGENT) == null) {
result.header(Network.USER_AGENT, Version.userAgent());
}
return result.build();
}
示例2: hasConditions
import com.squareup.okhttp.Request; //导入方法依赖的package包/类
private static boolean hasConditions(Request request) {
return (request.header("If-Modified-Since") == null && request.header("If-None-Match") == null) ? false : true;
}