AnsweredAssumed Answered

Using alf_method to simulate POST

Question asked by sigpaolo on Mar 27, 2012
Latest reply on Jun 26, 2012 by bkalbfus
I developed an application using webscripts in Alfresco 3.4. To reduce the number of webscripts often i declared webscripts supporting POST but i called them also with a GET using the parameter alf_method.

http://....../wcsevice/...?alf_method=POST&param1=….

Also indicated in this post
https://forums.alfresco.com/en/viewtopic.php?f=36&t=25633#p83399

In Alfresco 4.0 seems that these feature is no longer available. The wiki page of webscripts report that these feature (tunneling) is available only for POST call.

Looking into spring framework extension source code version 1.0.0 included in Alfresco I found the problem.
Class org.springframework.extensions.webscripts.servlet.WebScriptServletRuntime


protected String getScriptMethod()
    {
        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((new StringBuilder()).append("POST is tunnelling method '").append(overload).append("' as specified by ").append(overloadParam ? "alf_method parameter" : "X-HTTP-Method-Override header").toString());
                method = overload;
            }
        }
        return method;
    }

The problem is the if that check only the post method

Looking last release RC1 on subversion the "if" statement is


    if (method.equalsIgnoreCase("get") || method.equalsIgnoreCase("post"))

Thanks
Paolo

Outcomes