[ 
https://issues.apache.org/jira/browse/OFBIZ-10438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16520061#comment-16520061
 ] 

Shi Jinghai commented on OFBIZ-10438:
-------------------------------------

Hi Mathieu,

Amazing to see your patches, great work!

While I tested them in the following 3 cases, case 1 is OK, case 2 and 3 are 
not OK:

*CASE 1*: Loading and parsing speed of controller.xml:

The loading and parsing speeds with or without your patch in my local 
environment are same.

 

*CASE 2*: Error message when method not match:
 a. edit framework/webtools/webapp/webtools/WEB-INF/controller.xml, add 
method="post" to ping uri
{code:java}
<request-map uri="ping" method="post">
    <event type="service" invoke="ping"/>
    <response name="error" type="view" value="ping"/>
    <response name="success" type="view" value="ping"/>
</request-map>
{code}
b. visit [https://localhost:8443/webtools/control/ping] in browser
 c. error message:
{code:java}
org.apache.ofbiz.webapp.control.RequestHandlerException: Unknown request 
[ping]; this request does not exist or cannot be called directly.{code}
 

*CASE 3*: Without /control in uri (when we build openapi, we hope the uri can 
be as clean as possible):
 a. edit framework/webtools/webapp/webtools/WEB-INF/web.xml:
{code:java}
    // add /ping to allowedPaths
    <init-param>
        <param-name>allowedPaths</param-name>
        
<param-value>/ping:/ping.txt:/error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp</param-value>
    </init-param>

// change ControlServlet from /control/* to /*
<servlet-mapping>
    <servlet-name>ControlServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
{code}
b. edit framework/webtools/webapp/webtools/WEB-INF/controller.xml, remove 
method="post" from ping uri

c. visit [https://localhost:8443/webtools/ping] in browser

d. PONG is displayed correctly

e. edit framework/webtools/webapp/webtools/WEB-INF/controller.xml, add 
method="post" to ping uri

f. visit [https://localhost:8443/webtools/ping] in browser

g. error message:
{code:java}
ERROR in error page, (infinite loop or error page not found with name 
[/error/error.jsp]), but here is the text just in case it helps you: 
org.apache.ofbiz.webapp.control.RequestHandlerException: Unknown request 
[ping]; this request does not exist or cannot be called directly.
{code}
Maybe case 3 is out of scope of this issue, you can ignore it.

 

Kind Regards,

> Add method attribute to request-map to controll a uri can be called GET or 
> POST only
> ------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-10438
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10438
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Shi Jinghai
>            Assignee: Shi Jinghai
>            Priority: Minor
>         Attachments: 
> OFBIZ-10438_0001-Improved-Add-ControlServlet-service-method.patch, 
> OFBIZ-10438_0002-Improved-Add-optional-method-attribute-in-request-ma.patch, 
> OFBIZ-10438_0003-Improved-Factorize-default-request-search-in-Request.patch, 
> OFBIZ-10438_0004-Improved-Add-RequestHandler-resolveURI-method.patch
>
>
> As discussed in OFBIZ-4274, OFBiz runs doGet method in ControlServlet no 
> matter what request it is.
> I like Mathieu's comment on adding a method attribute to the request-map 
> element, it's almost the same as we implemented in our openapi:
>  
> {code:java}
> <request-map uri="examples" method="get">
>    <security https="true" auth="true"/>
>    <event type="java" path="ExamplesHandlers" invoke="getExamples"/>
>    <response name="success" type="view" value="..."/>
>    <response name="error" type="view" value="..."/>
> </request-map>
> {code}
>  The difference is that we DON'T support method list expression:
> {code:java}
> <request-map uri="examples" method="get,post">...</request-map>
> {code}
>   
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to