package com.proofpoint.jersey;

import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter;

/**
 * Clients may override the HTTP method by setting either the X-HTTP-Method-Override header or the _method form or query
 * parameter in a POST or GET request.  If both the X-HTTP-Method-Override header and _method parameter are present in
 * the request then the X-HTTP-Method-Override header will be used.
 */
public class OverrideMethodFilter
        implements ContainerRequestFilter
{
    private static final String HEADER = "X-HTTP-Method-Override";

    /**
     * The name of the form or query parameter that overrides the HTTP method.
     */
    public static final String METHOD = "_method";

    public ContainerRequest filter(ContainerRequest request)
    {
        if (request.getMethod().equalsIgnoreCase("POST") || request.getMethod().equalsIgnoreCase("GET")) {
            String method = request.getRequestHeaders().getFirst(HEADER);
            if (method == null || method.equals("")) {
                method = request.getQueryParameters().getFirst(METHOD);
            }

            if (method != null && !method.equals("")) {
                request.setMethod(method);
            }
        }

        return request;
    }
}

@@ -542,15 +542,101 @@
     
-private
+/**%0A     * The name of HTTP request header that overrides the HTTP method.%0A     */%0A    public
  sta
@@ -719,19 +719,11 @@
  of 
-the form or
+uri
  que
@@ -812,16 +812,22 @@
 g METHOD
+_PARAM
  = %22_met
@@ -1205,16 +1205,22 @@
 t(METHOD
+_PARAM
 );%0A     

change visibility, rename variable to make it clearer what it's for