本文整理汇总了Java中io.undertow.server.HttpServerExchange.isPersistent方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.isPersistent方法的具体用法?Java HttpServerExchange.isPersistent怎么用?Java HttpServerExchange.isPersistent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.server.HttpServerExchange
的用法示例。
在下文中一共展示了HttpServerExchange.isPersistent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleExplicitTransferEncoding
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private static StreamSinkConduit handleExplicitTransferEncoding(HttpServerExchange exchange, StreamSinkConduit channel, ConduitListener<StreamSinkConduit> finishListener, HeaderMap responseHeaders, String transferEncodingHeader, boolean headRequest) {
HttpString transferEncoding = new HttpString(transferEncodingHeader);
if (transferEncoding.equals(Headers.CHUNKED)) {
if (headRequest) {
return channel;
}
Boolean preChunked = exchange.getAttachment(HttpAttachments.PRE_CHUNKED_RESPONSE);
if(preChunked != null && preChunked) {
return new PreChunkedStreamSinkConduit(channel, finishListener, exchange);
} else {
return new ChunkedStreamSinkConduit(channel, exchange.getConnection().getBufferPool(), true, !exchange.isPersistent(), responseHeaders, finishListener, exchange);
}
} else {
if (headRequest) {
return channel;
}
log.trace("Cancelling persistence because response is identity with no content length");
// make it not persistent - very unfortunate for the next request handler really...
exchange.setPersistent(false);
responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString());
return new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
}
}
示例2: exchangeComplete
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public void exchangeComplete(final HttpServerExchange exchange) {
if (!exchange.isUpgrade() && exchange.isPersistent()) {
startRequest();
ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel();
channel.getReadSetter().set(this);
channel.wakeupReads();
} else if(!exchange.isPersistent()) {
safeClose(exchange.getConnection());
}
}
示例3: handleResponseConduit
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private static StreamSinkConduit handleResponseConduit(HttpServerExchange exchange, boolean headRequest, StreamSinkConduit channel, HeaderMap responseHeaders, ConduitListener<StreamSinkConduit> finishListener, String transferEncodingHeader) {
if (transferEncodingHeader == null) {
if (exchange.isHttp11()) {
if (exchange.isPersistent()) {
responseHeaders.put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString());
if (headRequest) {
return channel;
}
return new ChunkedStreamSinkConduit(channel, exchange.getConnection().getBufferPool(), true, !exchange.isPersistent(), responseHeaders, finishListener, exchange);
} else {
if (headRequest) {
return channel;
}
return new FinishableStreamSinkConduit(channel, finishListener);
}
} else {
exchange.setPersistent(false);
responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString());
if (headRequest) {
return channel;
}
return new FinishableStreamSinkConduit(channel, finishListener);
}
} else {
//moved outside because this is rarely used
//and makes the method small enough to be inlined
return handleExplicitTransferEncoding(exchange, channel, finishListener, responseHeaders, transferEncodingHeader, headRequest);
}
}
示例4: createSinkConduit
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
static StreamSinkConduit createSinkConduit(final HttpServerExchange exchange) {
DateUtils.addDateHeaderIfRequired(exchange);
boolean headRequest = exchange.getRequestMethod().equals(Methods.HEAD);
HttpServerConnection serverConnection = (HttpServerConnection) exchange.getConnection();
HttpResponseConduit responseConduit = serverConnection.getResponseConduit();
responseConduit.reset(exchange);
StreamSinkConduit channel = responseConduit;
if (headRequest) {
//if this is a head request we add a head channel underneath the content encoding channel
//this will just discard the data
//we still go through with the rest of the logic, to make sure all headers are set correctly
channel = new HeadStreamSinkConduit(channel, terminateResponseListener(exchange));
} else if(!Connectors.isEntityBodyAllowed(exchange)) {
//we are not allowed to send an entity body for some requests
exchange.getResponseHeaders().remove(Headers.CONTENT_LENGTH);
exchange.getResponseHeaders().remove(Headers.TRANSFER_ENCODING);
channel = new HeadStreamSinkConduit(channel, terminateResponseListener(exchange));
}
final HeaderMap responseHeaders = exchange.getResponseHeaders();
// test to see if we're still persistent
String connection = responseHeaders.getFirst(Headers.CONNECTION);
if (!exchange.isPersistent()) {
responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString());
} else if (exchange.isPersistent() && connection != null) {
if (HttpString.tryFromString(connection).equals(Headers.CLOSE)) {
exchange.setPersistent(false);
}
} else if (exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, true)) {
responseHeaders.put(Headers.CONNECTION, Headers.KEEP_ALIVE.toString());
}
//according to the HTTP RFC we should ignore content length if a transfer coding is specified
final String transferEncodingHeader = responseHeaders.getLast(Headers.TRANSFER_ENCODING);
if(transferEncodingHeader == null) {
final String contentLengthHeader = responseHeaders.getFirst(Headers.CONTENT_LENGTH);
if (contentLengthHeader != null) {
StreamSinkConduit res = handleFixedLength(exchange, headRequest, channel, responseHeaders, contentLengthHeader, serverConnection);
if (res != null) {
return res;
}
}
}
return handleResponseConduit(exchange, headRequest, channel, responseHeaders, terminateResponseListener(exchange), transferEncodingHeader);
}
示例5: reset
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
void reset(long contentLength, HttpServerExchange exchange) {
this.exchange = exchange;
super.reset(contentLength, !exchange.isPersistent());
}