-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8020d97
commit d3de045
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
uni-resolver-web/src/main/java/uniresolver/web/WebUniResolverWebServerFactoryCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package uniresolver.web; | ||
|
||
import org.eclipse.jetty.http.UriCompliance; | ||
import org.eclipse.jetty.server.Connector; | ||
import org.eclipse.jetty.server.HttpConfiguration; | ||
import org.eclipse.jetty.server.HttpConnectionFactory; | ||
import org.eclipse.jetty.server.Server; | ||
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; | ||
import org.springframework.boot.web.server.WebServerFactoryCustomizer; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class WebUniResolverWebServerFactoryCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory> { | ||
|
||
@Override | ||
public void customize(JettyServletWebServerFactory factory) { | ||
factory.addServerCustomizers(this::customizeUriCompliance); | ||
} | ||
|
||
private void customizeUriCompliance(Server server) { | ||
for (Connector connector : server.getConnectors()) { | ||
connector.getConnectionFactories().stream() | ||
.filter(factory -> factory instanceof HttpConnectionFactory) | ||
.forEach(factory -> { | ||
HttpConfiguration httpConfig = ((HttpConnectionFactory) factory).getHttpConfiguration(); | ||
httpConfig.setUriCompliance(UriCompliance.UNSAFE); | ||
}); | ||
} | ||
} | ||
} |