[I] [Task] [shenyu]</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=notifications@shenyu.apache.org&q=from:%22via+GitHub%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">via GitHub</span></span></a></span> <span class="date"><a href="/search?l=notifications@shenyu.apache.org&q=date:20260929" rel="nofollow">Tue, 29 Sep 2026 01:33:29 -0700</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre> yangjj-iso opened a new issue, #7369: URL: <a rel="nofollow" href="https://github.com/apache/shenyu/issues/7369">https://github.com/apache/shenyu/issues/7369</a></pre><pre> ### Description ### Feature Request Support form-urlencoded request bodies in the mock plugin's `MockRequest` so mock expressions can read form fields through `#req`. ### Is your feature request related to a problem? Please describe The mock plugin exposes the current request to expression generators as the `#req` variable: - `ExpressionGenerator#doGenerate` calls `context.setVariable("req", mockRequest)`. - `MockPlugin` builds `MockRequest` with headers, method, query parameters, URI, and the raw request body. `MockRequest` already exposes `getForms()`, but the method is currently unimplemented: ```java public Map<String, String> getForms() { //todo throw new UnsupportedOperationException(); } ``` As a result, a mock response expression that needs a field from an `application/x-www-form-urlencoded` request cannot use the request abstraction already exposed to SpEL. Calling `#req.forms` / `#req.getForms()` currently fails with `UnsupportedOperationException`. JSON request bodies do not have this limitation because `MockRequest#getJson()` already parses the raw body lazily. ### Describe the solution you'd like Implement `MockRequest#getForms()` for `application/x-www-form-urlencoded` request bodies. A possible implementation could: 1. Lazily parse the raw `body` into a `Map<String, String>`, similar to `getJson()`. 2. Decode percent-encoded keys and values as UTF-8. 3. Handle an empty body without throwing. 4. Cache the parsed form map on the `MockRequest` instance. 5. Add unit coverage for normal, encoded, and empty form bodies. 6. Add an expression-generator test proving that a form field can be read from `#req`. Example expected usage: ```text POST body: name=shenyu&message=hello%20world expression|#req.forms['name'] => "shenyu" ``` ### Describe alternatives you've considered The raw body could theoretically be parsed by callers, but `MockRequest` does not expose the raw request body and already defines a dedicated `getForms()` API. Implementing the existing API would also keep form-body access consistent with `getJson()`. ### Additional context Relevant files: - `shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/api/MockRequest.java` - `shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/MockPlugin.java` - `shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java` - `shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/StandardExpressionGenerator.java` I searched the current open and closed issues for `MockRequest`, `getForms`, and mock-plugin form-body support and did not find an existing issue covering this request. I am willing to submit a PR for this. ### Task List _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg38738.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="thrd2.html#38739">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="mail3.html#38739">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg38741.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email tSliceCur"><span class="subject">[I] [Task] <title> [shenyu]</span> <span class="sender italic">via GitHub</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg38741.html">Re: [I] [Task] Support form-urlencoded request bodies in t...</a></span> <span class="sender italic">via GitHub</span></li> <li class="icons-email"><span class="subject"><a href="msg39305.html">Re: [I] [Task] Support form-urlencoded request bodies in t...</a></span> <span class="sender italic">via GitHub</span></li> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="[I] [Task] <title> [shenyu]"> <input type="hidden" name="msgid" value="I_kwDOCGCHjs8AAAABT27GXQ@gitbox.apache.org"> <input type="hidden" name="relpath" value="notifications@shenyu.apache.org/msg38739.html"> <input type="submit" value=" via GitHub "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="notifications@shenyu.apache.org"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search notifications"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/notifications@shenyu.apache.org/">notifications - all messages</a></li> <li class="icons-about"><a href="/notifications@shenyu.apache.org/info.html">notifications - about the list</a></li> <li class="icons-expand"><a href="/search?l=notifications@shenyu.apache.org&q=subject:%22%5C%5BI%5C%5D+%5C%5BTask%5C%5D+%3Ctitle%3E+%5C%5Bshenyu%5C%5D%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg38738.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg38741.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">I_kwDOCGCHjs8AAAABT27GXQ@gitbox.apache.org</li> </ul> </div> </body> </html>