Interface HttpMethod

All Known Implementing Classes:
AbstractMethod, IdempotentMethod, Method, SafeMethod

public interface HttpMethod
Represents an HTTP method and provides static members for HTTP methods defined in RFC 7231, section 4.3 and RFC 5789
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HttpMethod
    HTTP Method CONNECT
    static final HttpMethod
    HTTP Method DELETE
    static final HttpMethod
    HTTP Method GET
    static final HttpMethod
    HTTP Method HEAD
    static final HttpMethod
    HTTP Method OPTIONS
    static final HttpMethod
    HTTP Method PATCH
    static final HttpMethod
    HTTP Method POST
    static final HttpMethod
    HTTP Method PUT
    static final HttpMethod
    HTTP Method TRACE
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns if this request method is idempotent, which means that sending multiple identical requests with that method has the same effect as sending one single request to the server.
    boolean
    Returns if this request method is safe, which means that the request is not intended and not expected to change any state on the server.
    boolean
    Returns whether this HttpMethod allows to send a message body.
    Returns the HTTP verb of this method.
  • Field Details

  • Method Details

    • verb

      String verb()
      Returns the HTTP verb of this method.
      Returns:
      A String containing the verb of the method.
    • isSafe

      boolean isSafe()
      Returns if this request method is safe, which means that the request is not intended and not expected to change any state on the server. In effect the semantics are to be considered read-only.
      See Also:
    • isIdempotent

      boolean isIdempotent()
      Returns if this request method is idempotent, which means that sending multiple identical requests with that method has the same effect as sending one single request to the server.
      See Also:
    • supportsRequestPayload

      boolean supportsRequestPayload()
      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 GET, HEAD, DELETE and 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.

      Returns:
      true if this method supports a message body, false otherwise.