<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"> </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. </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: <br><br>if(!exchange.getRequestMethod().equals(Methods.POST)) {<span class="Apple-converted-space"> </span><br>exchange.setResponseCode(405);<span class="Apple-converted-space"> </span><br>exchange.endExchange();<span class="Apple-converted-space"> </span><br>return;<span class="Apple-converted-space"> </span><br>}<span class="Apple-converted-space"> </span></div></div></span></blockquote></div><p>This way suits me, thank you. </p><p>How can I retrieve the POST parameters ? I only can access the GET ones with <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: <br><br>Handlers.predicate(Predicates.method(Methods.POST), postHandler, nonPostHandler);<span class="Apple-converted-space"> </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 ? </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) </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"> </span><br><br>----- Original Message -----<span class="Apple-converted-space"> </span><br>> From: "Samy Dindane" <samy@dindane.com><span class="Apple-converted-space"> </span><br>> To: undertow-dev@lists.jboss.org<span class="Apple-converted-space"> </span><br>> Sent: Sunday, 8 December, 2013 6:09:23 PM<span class="Apple-converted-space"> </span><br>> Subject: [undertow-dev] Force a HttpHandler to accept POST only<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> Hi folks,<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> I have a HttpHandler that I want to reach with POST requests only .<span class="Apple-converted-space"> </span><br>> I tried exchange.setRequestMethod(new HttpString("POST”)) inside<span class="Apple-converted-space"> </span><br>> handleRequest() , but the HttpHandler still responds to GET requests.<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> Is there any way to do this?<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> In case you’d like to check out the code, it can be found here .<span class="Apple-converted-space"> </span><br>> Thank you.<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> Samy<span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> _______________________________________________<span class="Apple-converted-space"> </span><br>> undertow-dev mailing list<span class="Apple-converted-space"> </span><br>> undertow-dev@lists.jboss.org<span class="Apple-converted-space"> </span><br>> https://lists.jboss.org/mailman/listinfo/undertow-dev<span class="Apple-converted-space"> </span><br></div></div></span></blockquote></div></div></div></body></html>