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


Java RecordedRequest.getHeader方法代码示例

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


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

示例1: upgradeResponse

import okhttp3.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
private MockResponse upgradeResponse(RecordedRequest request) {
  String key = request.getHeader("Sec-WebSocket-Key");
  return new MockResponse()
      .setStatus("HTTP/1.1 101 Switching Protocols")
      .setHeader("Connection", "Upgrade")
      .setHeader("Upgrade", "websocket")
      .setHeader("Sec-WebSocket-Accept", WebSocketProtocol.acceptHeader(key));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:WebSocketHttpTest.java

示例2: setIfModifiedSince

import okhttp3.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
/**
 * Confirm that {@link URLConnection#setIfModifiedSince} causes an If-Modified-Since header with a
 * GMT timestamp.
 *
 * https://code.google.com/p/android/issues/detail?id=66135
 */
@Test public void setIfModifiedSince() throws Exception {
  server.enqueue(new MockResponse().setBody("A"));

  URL url = server.url("/").url();
  URLConnection connection = urlFactory.open(url);
  connection.setIfModifiedSince(1393666200000L);
  assertEquals("A", readAscii(connection));
  RecordedRequest request = server.takeRequest();
  String ifModifiedSinceHeader = request.getHeader("If-Modified-Since");
  assertEquals("Sat, 01 Mar 2014 09:30:00 GMT", ifModifiedSinceHeader);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:UrlConnectionCacheTest.java

示例3: matchesHeader

import okhttp3.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
private boolean matchesHeader(RecordedRequest item, Description mismatchDescription) {
    String value = item.getHeader(first);
    if (value != null && !value.equals(second) || value == null && second != null) {
        mismatchDescription.appendText(first).appendText(" header was ").appendValue(value);
        return false;
    }

    return true;
}
 
开发者ID:auth0,项目名称:Guardian.java,代码行数:10,代码来源:RecordedRequestMatcher.java

示例4: assertRequestContainsHeader

import okhttp3.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
void assertRequestContainsHeader(String key, String expectedValue, int requestIndex)
  throws InterruptedException {
  RecordedRequest recordedRequest = obtainRecordedRequestAtIndex(requestIndex);
  String value = recordedRequest.getHeader(key);
  assertEquals(expectedValue, value);
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:7,代码来源:MockWebServerTest.java


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