Skip to content

XHTTP Method Override

Mihail Kuznetsov edited this page Mar 16, 2015 · 3 revisions

Using of X-HTTP-Method-Override HTTP header

X-HTTP-Method-Override HTTP header

EverRest has emedded support for X-HTTP-Method-Override HTTP headers. This is useful feature in case when client is not able make HTTP request with required HTTP method, e.g. cause firewall restriction.

For example if client need to make PUT request but not able to do that he can make POST request instead and add HTTP header X-HTTP-Method-Override with 'PUT' value. Server will process such header and do PUT request instead of POST. This feature is turned on by default to disable it set org.everrest.http.method.override context parameter to false in web.xml file:

    <context-param>
       <param-name>org.everrest.http.method.override</param-name>
       <param-value>false</param-value>
    </context-param>

Usage:

  • Create service with following content:
@Path("a")
public class MyResource
{
   @PUT
   @Path("b")
   public String put()
   {
      return "PUT method";
   }
}
  • Deploy it servlet container, see ServletsIntegration.
  • Try accees to service via curl. If you under linux or other unix like OS it is often already installed at your system.
curl -X POST \
-H "X-HTTP-Method-Override:PUT" \
http://localhost:8080/{CONTEXT_NAME}/a/b

As result you should see response PUT method at your console.