On Thu, Jul 3, 2008 at 2:54 PM, Oscar Westra van Holthe - Kind <
[EMAIL PROTECTED]> wrote:
> On 03-07-2008 at 13:58, Ben Gunter wrote:
> > I would probably do something like this in a base class and let
> subclasses
> > override the Java methods that correspond to the HTTP methods they want
> to
> > support.
> >
> > protected RuntimeException getException(String method) {
> > return new UnsupportedOperationException("Method " + method + "
> is
> > not supported by "
> > + getClass());
> > }
> >
> > @DefaultHandler
> > public Resolution execute() {
> > String method = getContext().getRequest().getMethod();
> > if ("GET".equalsIgnoreCase(method)) {
> > return GET();
> > } else if ("POST".equalsIgnoreCase(method)) {
> > return POST();
> > } else if ("PUT".equalsIgnoreCase(method)) {
> > return PUT();
> > } else if ("DELETE".equalsIgnoreCase(method)) {
> > return DELETE();
> > } else {
> > throw getException(method);
> > }
> > }
> [...]
>
> For GET and POST this will work. However, Stripes does not call the
> ActionBean for the other request methods. So PUT and DELETE will not work.
> I assume this is because the HTML specification only allows the use of the
> GET and POST HTTP request methods.
>
> To change this, we'd need several changes:
> - Binding and validation must now take into account that the request body
> doesn't contain input parameters (like for a POST request), but a binary
> blob that is to be put somewhere. Or alternatively, the InputStream of the
> request is left alone so the programmer can read the request himself
> (which
> the ActionBeanContext was supposed to abstract away from).
> - The DispatcherServlet must re-implement the service() method, to detect
> the
> request methods HEAD, OPTIONS and TRACE, and direct them to the
> appropriate
> handler in HttpServlet. Other calls ultimately redirect to doPost(...),
> like GET and POST do mow.
>
> All in all, I'm not certain if this can be done cleanly easily.
>
>
> Oscar
Both good points. I believe for a POST request, the input stream will only
be read if the content type is either application/x-www-form-urlencoded (by
the container) or multipart/form-data (by a multipart wrapper via Stripes).
If you use a content type other than those two you should be OK. As for the
second point, you could subclass DispatcherServlet and override service(..)
to call doPost(..) in all cases.
-Ben
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users