dev@grizzly.java.net

How to return a different response status

From: James Lorenzen <jlorenzen_at_gestalt-llc.com>
Date: Thu, 31 May 2007 17:03:18 -0500

I am using Grizzly in a simple way to process HTTP GET requests for an
RSS Reader.

However I am trying to set the response status for different events.
Unfortunately this doesn't work.

 

public void service(final Request request, final Response response)
throws Exception {

        if (!request.method().toString().equalsIgnoreCase("GET")) {

            response.setStatus(HttpURLConnection.HTTP_BAD_METHOD);

            response.finish();

            return;

        }

 

When this starts up and I send a POST request I expect a 405, but that
doesn't happen. What am I doing wrong?