use of io.undertow.attribute.ReadOnlyAttributeException in project undertow by undertow-io.
the class ExtendedAccessLogParser method getXParameterElement.
protected ExchangeAttribute getXParameterElement(PatternTokenizer tokenizer) throws IOException {
if (!tokenizer.hasSubToken()) {
UndertowLogger.ROOT_LOGGER.extendedAccessLogBadXParam();
return null;
}
final String token = tokenizer.getToken();
if (!tokenizer.hasParameter()) {
UndertowLogger.ROOT_LOGGER.extendedAccessLogBadXParam();
return null;
}
String parameter = tokenizer.getParameter();
if (parameter == null) {
UndertowLogger.ROOT_LOGGER.extendedAccessLogMissingClosing();
return null;
}
if ("A".equals(token)) {
return new SubstituteEmptyWrapper.SubstituteEmptyAttribute(parser.parse("%{sc," + parameter + "}"), "-");
} else if ("C".equals(token)) {
return new SubstituteEmptyWrapper.SubstituteEmptyAttribute(new CookieAttribute(parameter), "-");
} else if ("R".equals(token)) {
return parser.parse("%{r," + parameter + "}");
} else if ("S".equals(token)) {
return new SubstituteEmptyWrapper.SubstituteEmptyAttribute(parser.parse("%{s," + parameter + "}"), "-");
} else if ("H".equals(token)) {
return getServletRequestElement(parameter);
} else if ("P".equals(token)) {
return new SubstituteEmptyWrapper.SubstituteEmptyAttribute(parser.parse("%{rp," + parameter + "}"), "-");
} else if ("O".equals(token)) {
return new QuotingExchangeAttribute(new ExchangeAttribute() {
@Override
public String readAttribute(HttpServerExchange exchange) {
HeaderValues values = exchange.getResponseHeaders().get(parameter);
if (values != null && values.size() > 0) {
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < values.size(); i++) {
String string = values.get(i);
buffer.append(string);
if (i + 1 < values.size())
buffer.append(",");
}
return buffer.toString();
}
return null;
}
@Override
public void writeAttribute(HttpServerExchange exchange, String newValue) throws ReadOnlyAttributeException {
throw new ReadOnlyAttributeException();
}
});
}
UndertowLogger.ROOT_LOGGER.extendedAccessLogCannotDecodeXParamValue(token);
return null;
}
Aggregations