本文整理汇总了Java中okhttp3.internal.http2.Http2Codec类的典型用法代码示例。如果您正苦于以下问题:Java Http2Codec类的具体用法?Java Http2Codec怎么用?Java Http2Codec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Http2Codec类属于okhttp3.internal.http2包,在下文中一共展示了Http2Codec类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newCodec
import okhttp3.internal.http2.Http2Codec; //导入依赖的package包/类
public HttpCodec newCodec(
OkHttpClient client, StreamAllocation streamAllocation) throws SocketException {
if (http2Connection != null) {
return new Http2Codec(client, streamAllocation, http2Connection);
} else {
socket.setSoTimeout(client.readTimeoutMillis());
source.timeout().timeout(client.readTimeoutMillis(), MILLISECONDS);
sink.timeout().timeout(client.writeTimeoutMillis(), MILLISECONDS);
return new Http1Codec(client, streamAllocation, source, sink);
}
}
示例2: readNameValueBlockDropsForbiddenHeadersHttp2
import okhttp3.internal.http2.Http2Codec; //导入依赖的package包/类
@Test public void readNameValueBlockDropsForbiddenHeadersHttp2() throws IOException {
List<Header> headerBlock = headerEntries(
":status", "200 OK",
":version", "HTTP/1.1",
"connection", "close");
Request request = new Request.Builder().url("http://square.com/").build();
Response response = Http2Codec.readHttp2HeadersList(headerBlock).request(request).build();
Headers headers = response.headers();
assertEquals(1, headers.size());
assertEquals(":version", headers.name(0));
assertEquals("HTTP/1.1", headers.value(0));
}
示例3: http2HeadersListDropsForbiddenHeadersHttp2
import okhttp3.internal.http2.Http2Codec; //导入依赖的package包/类
@Test public void http2HeadersListDropsForbiddenHeadersHttp2() {
Request request = new Request.Builder()
.url("http://square.com/")
.header("Connection", "upgrade")
.header("Upgrade", "websocket")
.header("Host", "square.com")
.build();
List<Header> expected = headerEntries(
":method", "GET",
":path", "/",
":authority", "square.com",
":scheme", "http");
assertEquals(expected, Http2Codec.http2HeadersList(request));
}
示例4: newCodec
import okhttp3.internal.http2.Http2Codec; //导入依赖的package包/类
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain,
StreamAllocation streamAllocation) throws SocketException {
if (http2Connection != null) {
return new Http2Codec(client, chain, streamAllocation, http2Connection);
} else {
socket.setSoTimeout(chain.readTimeoutMillis());
source.timeout().timeout(chain.readTimeoutMillis(), MILLISECONDS);
sink.timeout().timeout(chain.writeTimeoutMillis(), MILLISECONDS);
return new Http1Codec(client, streamAllocation, source, sink);
}
}
示例5: http2HeadersListDropsForbiddenHeadersHttp2
import okhttp3.internal.http2.Http2Codec; //导入依赖的package包/类
@Test public void http2HeadersListDropsForbiddenHeadersHttp2() {
Request request = new Request.Builder()
.url("http://square.com/")
.header("Connection", "upgrade")
.header("Upgrade", "websocket")
.build();
List<Header> expected = headerEntries(
":method", "GET",
":path", "/",
":authority", "square.com",
":scheme", "http");
assertEquals(expected, Http2Codec.http2HeadersList(request));
}