本文整理汇总了Java中io.undertow.server.HttpServerExchange.getResponseContentLength方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.getResponseContentLength方法的具体用法?Java HttpServerExchange.getResponseContentLength怎么用?Java HttpServerExchange.getResponseContentLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.server.HttpServerExchange
的用法示例。
在下文中一共展示了HttpServerExchange.getResponseContentLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrap
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public StreamSinkConduit wrap(final ConduitFactory<StreamSinkConduit> factory, final HttpServerExchange exchange) {
if (exchange.getResponseHeaders().contains(Headers.CONTENT_ENCODING)) {
//already encoded
return factory.create();
}
//if this is a zero length response we don't want to encode
if (exchange.getResponseContentLength() != 0
&& exchange.getResponseCode() != StatusCodes.NO_CONTENT
&& exchange.getResponseCode() != StatusCodes.NOT_MODIFIED) {
EncodingMapping encoding = getEncoding();
if (encoding != null) {
exchange.getResponseHeaders().put(Headers.CONTENT_ENCODING, encoding.getName());
if (exchange.getRequestMethod().equals(Methods.HEAD)) {
//we don't create an actual encoder for HEAD requests, but we set the header
return factory.create();
} else {
return encoding.getEncoding().getResponseWrapper().wrap(factory, exchange);
}
}
}
return factory.create();
}
示例2: logMessage
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public void logMessage(String pattern, HttpServerExchange exchange) {
JDBCLogAttribute jdbcLogAttribute = new JDBCLogAttribute();
if (pattern.equals("combined")) {
jdbcLogAttribute.pattern = pattern;
}
jdbcLogAttribute.remoteHost = ((InetSocketAddress) exchange.getConnection().getPeerAddress()).getAddress().getHostAddress();
SecurityContext sc = exchange.getSecurityContext();
if (sc == null || !sc.isAuthenticated()) {
jdbcLogAttribute.user = null;
} else {
jdbcLogAttribute.user = sc.getAuthenticatedAccount().getPrincipal().getName();
}
jdbcLogAttribute.query = exchange.getQueryString();
jdbcLogAttribute.bytes = exchange.getResponseContentLength();
if (jdbcLogAttribute.bytes < 0)
jdbcLogAttribute.bytes = 0;
jdbcLogAttribute.status = exchange.getResponseCode();
if (jdbcLogAttribute.pattern.equals("combined")) {
jdbcLogAttribute.virtualHost = exchange.getRequestHeaders().getFirst(Headers.HOST);
jdbcLogAttribute.method = exchange.getRequestMethod().toString();
jdbcLogAttribute.referer = exchange.getRequestHeaders().getFirst(Headers.REFERER);
jdbcLogAttribute.userAgent = exchange.getRequestHeaders().getFirst(Headers.USER_AGENT);
}
this.pendingMessages.add(jdbcLogAttribute);
int state = stateUpdater.get(this);
if (state == 0) {
if (stateUpdater.compareAndSet(this, 0, 1)) {
logWriteExecutor.execute(this);
}
}
}
示例3: UndertowOutputStream
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
* Construct a new instance. No write timeout is configured.
*
* @param exchange The exchange
*/
public UndertowOutputStream(HttpServerExchange exchange) {
this.exchange = exchange;
this.contentLength = exchange.getResponseContentLength();
}