use of io.undertow.attribute.ConstantExchangeAttribute in project undertow by undertow-io.
the class ExtendedAccessLogParser method getProxyElement.
protected ExchangeAttribute getProxyElement(PatternTokenizer tokenizer) throws IOException {
String token = null;
if (tokenizer.hasSubToken()) {
tokenizer.getToken();
return new ConstantExchangeAttribute("-");
} else if (tokenizer.hasParameter()) {
tokenizer.getParameter();
return new ConstantExchangeAttribute("-");
}
UndertowLogger.ROOT_LOGGER.extendedAccessLogCannotDecode(token);
return null;
}
use of io.undertow.attribute.ConstantExchangeAttribute in project undertow by undertow-io.
the class ExtendedAccessLogParser method parse.
public ExchangeAttribute parse(String pattern) {
List<ExchangeAttribute> list = new ArrayList<ExchangeAttribute>();
PatternTokenizer tokenizer = new PatternTokenizer(pattern);
try {
// Ignore leading whitespace.
tokenizer.getWhiteSpaces();
if (tokenizer.isEnded()) {
UndertowLogger.ROOT_LOGGER.extendedAccessLogEmptyPattern();
return null;
}
String token = tokenizer.getToken();
while (token != null) {
if (UndertowLogger.ROOT_LOGGER.isDebugEnabled()) {
UndertowLogger.ROOT_LOGGER.debug("token = " + token);
}
ExchangeAttribute element = getLogElement(token, tokenizer);
if (element == null) {
break;
}
list.add(element);
String whiteSpaces = tokenizer.getWhiteSpaces();
if (whiteSpaces.length() > 0) {
list.add(new ConstantExchangeAttribute(whiteSpaces));
}
if (tokenizer.isEnded()) {
break;
}
token = tokenizer.getToken();
}
if (UndertowLogger.ROOT_LOGGER.isDebugEnabled()) {
UndertowLogger.ROOT_LOGGER.debug("finished decoding with element size of: " + list.size());
}
return new CompositeExchangeAttribute(list.toArray(new ExchangeAttribute[list.size()]));
} catch (IOException e) {
UndertowLogger.ROOT_LOGGER.extendedAccessLogPatternParseError(e);
return null;
}
}
Aggregations