當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。