Web Scripts:

- allow tunelling of arbitrary http methods via POST (for clients who have restricted HTTP vocabulary support)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5849 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-06-05 12:02:25 +00:00
parent ac9960758f
commit 7b09497a8f
3 changed files with 101 additions and 1 deletions

View File

@@ -70,7 +70,27 @@ public class WebScriptServletRuntime extends WebScriptRuntime
@Override
protected String getScriptMethod()
{
return req.getMethod();
// Is this an overloaded POST request?
String method = req.getMethod();
if (method.equalsIgnoreCase("post"))
{
boolean overloadParam = false;
String overload = req.getHeader("X-HTTP-Method-Override");
if (overload == null || overload.length() == 0)
{
overload = req.getParameter("alf:method");
overloadParam = true;
}
if (overload != null && overload.length() > 0)
{
if (logger.isDebugEnabled())
logger.debug("POST is tunnelling method '" + overload + "' as specified by " + (overloadParam ? "alf:method parameter" : "X-HTTP-Method-Override header"));
method = overload;
}
}
return method;
}
/* (non-Javadoc)