<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><span style="color: rgb(160, 160, 168);">On 9 décembre 2013 at 11:10:49, Stuart Douglas (</span><a href="mailto://sdouglas@redhat.com">sdouglas@redhat.com</a><span style="color: rgb(160, 160, 168);">) wrote:</span></div> <div><blockquote type="cite" class="clean_bq" style="font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span><div><div>What do you want to happen if it is not a post request?<span class="Apple-converted-space">&nbsp;</span></div></div></span></blockquote></div><p><div style="color: rgb(0, 0, 0); font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote class="clean_bq"><div></div></blockquote></div></p><p style="color: rgb(0, 0, 0); font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I was thinking about a 404 error, but indeed, 405 is more relevant.&nbsp;</p><div><div><blockquote type="cite" class="clean_bq" style="font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span><div><div>The simplest way is just:&nbsp;<br><br>if(!exchange.getRequestMethod().equals(Methods.POST)) {<span class="Apple-converted-space">&nbsp;</span><br>exchange.setResponseCode(405);<span class="Apple-converted-space">&nbsp;</span><br>exchange.endExchange();<span class="Apple-converted-space">&nbsp;</span><br>return;<span class="Apple-converted-space">&nbsp;</span><br>}<span class="Apple-converted-space">&nbsp;</span></div></div></span></blockquote></div><p>This way suits me, thank you.&nbsp;</p><p>How can I retrieve the POST parameters ? I only can access the GET ones with&nbsp;<i>getQueryParameters()</i>.</p><div><div><blockquote type="cite" class="clean_bq" style="font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span><div><div>If you want to pick a handler to invoke based on the method you can use:&nbsp;<br><br>Handlers.predicate(Predicates.method(Methods.POST), postHandler, nonPostHandler);<span class="Apple-converted-space">&nbsp;</span></div></div></span></blockquote></div><p>Do you think it’s a good idea to create a handler for any 404 error page and use it here ?&nbsp;</p><p>If so, is it possible to set it as the default handler for all 404 errors ? (I can do the check manually but I’m wondering if it is supported by default)&nbsp;</p><div><blockquote type="cite" class="clean_bq" style="font-family: helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span><div><div><br><br>Stuart<span class="Apple-converted-space">&nbsp;</span><br><br>----- Original Message -----<span class="Apple-converted-space">&nbsp;</span><br>&gt; From: "Samy Dindane" &lt;samy@dindane.com&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; To: undertow-dev@lists.jboss.org<span class="Apple-converted-space">&nbsp;</span><br>&gt; Sent: Sunday, 8 December, 2013 6:09:23 PM<span class="Apple-converted-space">&nbsp;</span><br>&gt; Subject: [undertow-dev] Force a HttpHandler to accept POST only<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; Hi folks,<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; I have a HttpHandler that I want to reach with POST requests only .<span class="Apple-converted-space">&nbsp;</span><br>&gt; I tried exchange.setRequestMethod(new HttpString("POST”)) inside<span class="Apple-converted-space">&nbsp;</span><br>&gt; handleRequest() , but the HttpHandler still responds to GET requests.<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; Is there any way to do this?<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; In case you’d like to check out the code, it can be found here .<span class="Apple-converted-space">&nbsp;</span><br>&gt; Thank you.<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; Samy<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; _______________________________________________<span class="Apple-converted-space">&nbsp;</span><br>&gt; undertow-dev mailing list<span class="Apple-converted-space">&nbsp;</span><br>&gt; undertow-dev@lists.jboss.org<span class="Apple-converted-space">&nbsp;</span><br>&gt; https://lists.jboss.org/mailman/listinfo/undertow-dev<span class="Apple-converted-space">&nbsp;</span><br></div></div></span></blockquote></div></div></div></body></html>