本文整理匯總了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);
}