I'm trying to fix AMBIGUOUS_EMPTY_SEGMENT errors in a Spring Boot application that builds on embedded Jetty. I think I want to use https://eclipse.dev/jetty/javadoc/jetty-12/org/eclipse/jetty/rewrite/handler/CompactPathRule.html but the documentation doesn't really explain how to enable the rule.
I have already allowed this violation and added a listener for violations. The listener never gets triggered. If I remove the custom Uri compliance, the listener starts getting hits. Seems like rewriting the URLs is easier than really allowing the empty path segments. There is a ticket about this on Jetty https://github.com/jetty/jetty.project/issues/11448
HttpConnectionFactory connFac = conn.getConnectionFactory(HttpConnectionFactory.class); Set<UriCompliance.Violation> violations = new HashSet<>(); violations.add(UriCompliance.Violation.AMBIGUOUS_EMPTY_SEGMENT); UriCompliance customUriCompliance = new UriCompliance("Custom", violations); connFac.getHttpConfiguration().addComplianceViolationListener(new ComplianceViolation.Listener() { @Override public void onComplianceViolation(ComplianceViolation.Event event) { ComplianceViolation.Listener.super.onComplianceViolation(event); System.err.println("COMPLIANCE VIOLATION"); } }); connFac.getHttpConfiguration().setUriCompliance(customUriCompliance);
Most of the semi-related questions on Stack Overflow talk about editing various XML files, none of which seem to exist in a Spring Boot project.