Class AbstractMethod

java.lang.Object
org.dmfs.httpessentials.methods.AbstractMethod
All Implemented Interfaces:
HttpMethod
Direct Known Subclasses:
IdempotentMethod, Method, SafeMethod

public abstract class AbstractMethod extends Object implements HttpMethod
An abstract HttpMethod. By default this method is not safe and not idempotent.
  • Constructor Details

    • AbstractMethod

      public AbstractMethod(String verb, boolean supportsRequestPayload)
      Instantiates a new HttpMethod with the given verb.
      Parameters:
      verb - The method verb.
      supportsRequestPayload - whether this method support sending a request message body.
  • Method Details

    • verb

      public final String verb()
      Description copied from interface: HttpMethod
      Returns the HTTP verb of this method.
      Specified by:
      verb in interface HttpMethod
      Returns:
      A String containing the verb of the method.
    • supportsRequestPayload

      public final boolean supportsRequestPayload()
      Description copied from interface: HttpMethod
      Returns whether this HttpMethod allows to send a message body.

      Note that RFC 7231 does not explicitly forbid a message payload for some methods (in particular these are HttpMethod.GET, HttpMethod.HEAD, HttpMethod.DELETE and HttpMethod.CONNECT). Instead is says something like this:

       A payload within a XXX request message has no defined semantics;
       sending a payload body on a XXX request might cause some existing
       implementations to reject the request.
       

      The predefined methods in HttpMethod interpret this rather strict and return false for such methods.

      Specified by:
      supportsRequestPayload in interface HttpMethod
      Returns:
      true if this method supports a message body, false otherwise.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object