-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for Spring Boot HEAD error handling bug
Due to this Spring Boot issue: spring-projects/spring-boot#23551 StoRM WebDAV was returning body for head requests that resulted in error. Until Spring Boot 2.2.11 is released here there's a workaround (that basically incorporates the upstream code fix here).
- Loading branch information
1 parent
16ffbc6
commit ae83379
Showing
2 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/italiangrid/storm/webdav/server/util/JettyErrorPageHandler.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,33 @@ | ||
package org.italiangrid.storm.webdav.server.util; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler; | ||
|
||
public class JettyErrorPageHandler extends ErrorPageErrorHandler { | ||
|
||
private static final Set<String> HANDLED_HTTP_METHODS = | ||
new HashSet<>(Arrays.asList("GET", "POST", "HEAD")); | ||
|
||
@Override | ||
public boolean errorPageForMethod(String method) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void handle(String target, Request baseRequest, HttpServletRequest request, | ||
HttpServletResponse response) throws IOException { | ||
if (!HANDLED_HTTP_METHODS.contains(baseRequest.getMethod())) { | ||
baseRequest.setMethod("GET"); | ||
} | ||
super.doError(target, baseRequest, request, response); | ||
} | ||
|
||
} |