Search in sources :

Example 1 with ConstantExchangeAttribute

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;
}
Also used : ConstantExchangeAttribute(io.undertow.attribute.ConstantExchangeAttribute) HttpString(io.undertow.util.HttpString)

Example 2 with ConstantExchangeAttribute

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;
    }
}
Also used : ConstantExchangeAttribute(io.undertow.attribute.ConstantExchangeAttribute) CompositeExchangeAttribute(io.undertow.attribute.CompositeExchangeAttribute) SecureExchangeAttribute(io.undertow.attribute.SecureExchangeAttribute) AuthenticationTypeExchangeAttribute(io.undertow.attribute.AuthenticationTypeExchangeAttribute) ConstantExchangeAttribute(io.undertow.attribute.ConstantExchangeAttribute) ExchangeAttribute(io.undertow.attribute.ExchangeAttribute) CompositeExchangeAttribute(io.undertow.attribute.CompositeExchangeAttribute) QuotingExchangeAttribute(io.undertow.attribute.QuotingExchangeAttribute) ArrayList(java.util.ArrayList) HttpString(io.undertow.util.HttpString) IOException(java.io.IOException)

Aggregations

ConstantExchangeAttribute (io.undertow.attribute.ConstantExchangeAttribute)2 HttpString (io.undertow.util.HttpString)2 AuthenticationTypeExchangeAttribute (io.undertow.attribute.AuthenticationTypeExchangeAttribute)1 CompositeExchangeAttribute (io.undertow.attribute.CompositeExchangeAttribute)1 ExchangeAttribute (io.undertow.attribute.ExchangeAttribute)1 QuotingExchangeAttribute (io.undertow.attribute.QuotingExchangeAttribute)1 SecureExchangeAttribute (io.undertow.attribute.SecureExchangeAttribute)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1