下面列出了 io.netty.handler.codec.http.cookie.ServerCookieDecoder # STRICT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressWarnings("FutureReturnValueIgnored")
private void doTestStatus(HttpResponseStatus status) {
EmbeddedChannel channel = new EmbeddedChannel();
HttpServerOperations ops = new HttpServerOperations(
Connection.from(channel),
ConnectionObserver.emptyListener(),
null,
new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"),
null,
ServerCookieEncoder.STRICT,
ServerCookieDecoder.STRICT);
ops.status(status);
HttpMessage response = ops.newFullBodyMessage(Unpooled.EMPTY_BUFFER);
assertThat(((FullHttpResponse) response).status().reasonPhrase()).isEqualTo(status.reasonPhrase());
// "FutureReturnValueIgnored" is suppressed deliberately
channel.close();
}
/**
* Configure the
* {@link ServerCookieEncoder}; {@link ServerCookieDecoder} will be
* chosen based on the encoder
*
* @param encoder the preferred ServerCookieEncoder
*
* @return a new {@link HttpServer}
*/
public final HttpServer cookieCodec(ServerCookieEncoder encoder) {
Objects.requireNonNull(encoder, "encoder");
ServerCookieDecoder decoder = encoder == ServerCookieEncoder.LAX ?
ServerCookieDecoder.LAX : ServerCookieDecoder.STRICT;
HttpServer dup = duplicate();
dup.configuration().cookieEncoder = encoder;
dup.configuration().cookieDecoder = decoder;
return dup;
}
HttpServerConfig(Map<ChannelOption<?>, ?> options, Map<ChannelOption<?>, ?> childOptions, Supplier<? extends SocketAddress> localAddress) {
super(options, childOptions, localAddress);
this.cookieDecoder = ServerCookieDecoder.STRICT;
this.cookieEncoder = ServerCookieEncoder.STRICT;
this.decoder = new HttpRequestDecoderSpec();
this.forwarded = false;
this.minCompressionSize = -1;
this.protocols = new HttpProtocol[]{HttpProtocol.HTTP11};
this._protocols = h11;
this.proxyProtocolSupportType = ProxyProtocolSupportType.OFF;
}