当前位置: 首页>>代码示例>>Java>>正文


Java HttpHeaders.varyHeaders方法代码示例

本文整理汇总了Java中okhttp3.internal.http.HttpHeaders.varyHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.varyHeaders方法的具体用法?Java HttpHeaders.varyHeaders怎么用?Java HttpHeaders.varyHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在okhttp3.internal.http.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.varyHeaders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Entry

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
public Entry(Response response) {
  this.url = response.request().url().toString();
  this.varyHeaders = HttpHeaders.varyHeaders(response);
  this.requestMethod = response.request().method();
  this.protocol = response.protocol();
  this.code = response.code();
  this.message = response.message();
  this.responseHeaders = response.headers();
  this.handshake = response.handshake();
  this.sentRequestMillis = response.sentRequestAtMillis();
  this.receivedResponseMillis = response.receivedResponseAtMillis();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Cache.java

示例2: Entry

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
Entry(Response response) {
  this.url = response.request().url().toString();
  this.varyHeaders = HttpHeaders.varyHeaders(response);
  this.requestMethod = response.request().method();
  this.protocol = response.protocol();
  this.code = response.code();
  this.message = response.message();
  this.responseHeaders = response.headers();
  this.handshake = response.handshake();
  this.sentRequestMillis = response.sentRequestAtMillis();
  this.receivedResponseMillis = response.receivedResponseAtMillis();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Cache.java

示例3: Entry

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
public Entry(Response response) {
    this.url = response.request().url().toString();
    this.varyHeaders = HttpHeaders.varyHeaders(response);
    this.requestMethod = response.request().method();
    this.protocol = response.protocol();
    this.code = response.code();
    this.message = response.message();
    this.responseHeaders = response.headers();
    this.handshake = response.handshake();
    this.sentRequestMillis = response.sentRequestAtMillis();
    this.receivedResponseMillis = response.receivedResponseAtMillis();
}
 
开发者ID:RunningTheSnail,项目名称:Okhttp,代码行数:13,代码来源:Cache.java

示例4: ResponseHeaderRecord

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
ResponseHeaderRecord(Response response) {
  this.url = response.request().url().toString();
  this.varyHeaders = HttpHeaders.varyHeaders(response);
  this.requestMethod = response.request().method();
  this.protocol = response.protocol();
  this.code = response.code();
  this.message = response.message();
  this.responseHeaders = response.headers();
  this.handshake = response.handshake();
  this.sentRequestMillis = response.sentRequestAtMillis();
  this.receivedResponseMillis = response.receivedResponseAtMillis();
}
 
开发者ID:apollographql,项目名称:apollo-android,代码行数:13,代码来源:ResponseHeaderRecord.java

示例5: createOkResponseForCacheGet

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
/**
 * Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
 * to supply the data.
 */
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
    throws IOException {

  // Build a cache request for the response to use.
  Headers responseHeaders = createHeaders(javaResponse.getHeaders());
  Headers varyHeaders;
  if (HttpHeaders.hasVaryAll(responseHeaders)) {
    // "*" means that this will be treated as uncacheable anyway.
    varyHeaders = new Headers.Builder().build();
  } else {
    varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
  }

  Request cacheRequest = new Request.Builder()
      .url(request.url())
      .method(request.method(), null)
      .headers(varyHeaders)
      .build();

  Response.Builder okResponseBuilder = new Response.Builder();

  // Request: Use the cacheRequest we built.
  okResponseBuilder.request(cacheRequest);

  // Status line: Java has this as one of the headers.
  StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
  okResponseBuilder.protocol(statusLine.protocol);
  okResponseBuilder.code(statusLine.code);
  okResponseBuilder.message(statusLine.message);

  // Response headers
  Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
  okResponseBuilder.headers(okHeaders);

  // Response body
  ResponseBody okBody = createOkBody(okHeaders, javaResponse);
  okResponseBuilder.body(okBody);

  // Handle SSL handshake information as needed.
  if (javaResponse instanceof SecureCacheResponse) {
    SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;

    // Handshake doesn't support null lists.
    List<Certificate> peerCertificates;
    try {
      peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
      peerCertificates = Collections.emptyList();
    }
    List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
    if (localCertificates == null) {
      localCertificates = Collections.emptyList();
    }

    String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
    CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
    Handshake handshake = Handshake.get(null, cipherSuite, peerCertificates, localCertificates);
    okResponseBuilder.handshake(handshake);
  }

  return okResponseBuilder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:67,代码来源:JavaApiConverter.java

示例6: createOkResponseForCacheGet

import okhttp3.internal.http.HttpHeaders; //导入方法依赖的package包/类
/**
 * Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
 * to supply the data.
 */
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
    throws IOException {

  // Build a cache request for the response to use.
  Headers responseHeaders = createHeaders(javaResponse.getHeaders());
  Headers varyHeaders;
  if (HttpHeaders.hasVaryAll(responseHeaders)) {
    // "*" means that this will be treated as uncacheable anyway.
    varyHeaders = new Headers.Builder().build();
  } else {
    varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
  }

  Request cacheRequest = new Request.Builder()
      .url(request.url())
      .method(request.method(), null)
      .headers(varyHeaders)
      .build();

  Response.Builder okResponseBuilder = new Response.Builder();

  // Request: Use the cacheRequest we built.
  okResponseBuilder.request(cacheRequest);

  // Status line: Java has this as one of the headers.
  StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
  okResponseBuilder.protocol(statusLine.protocol);
  okResponseBuilder.code(statusLine.code);
  okResponseBuilder.message(statusLine.message);

  // Response headers
  Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
  okResponseBuilder.headers(okHeaders);

  // Response body
  ResponseBody okBody = createOkBody(okHeaders, javaResponse);
  okResponseBuilder.body(okBody);

  // Handle SSL handshake information as needed.
  if (javaResponse instanceof SecureCacheResponse) {
    SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;

    // Handshake doesn't support null lists.
    List<Certificate> peerCertificates;
    try {
      peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
      peerCertificates = Collections.emptyList();
    }
    List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
    if (localCertificates == null) {
      localCertificates = Collections.emptyList();
    }

    String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
    CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
    Handshake handshake = Handshake.get(
        TlsVersion.SSL_3_0, cipherSuite, peerCertificates, localCertificates);
    okResponseBuilder.handshake(handshake);
  }

  return okResponseBuilder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:68,代码来源:JavaApiConverter.java


注:本文中的okhttp3.internal.http.HttpHeaders.varyHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。