本文整理汇总了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));
}
示例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);
}
示例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;
}
示例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);
}