Class Method

java.lang.Object
io.helidon.http.Method

public final class Method extends Object
Interface representing an HTTP request method, all standard methods are in Method enumeration.

Although the constants are instances of this class, they can be compared using instance equality, as the only way to obtain an instance is through method create(String), which ensures the same instance is returned for known methods.

Methods that are not known (e.g. there is no constant for them) must be compared using equals(Object) as usual.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Method
    The HTTP CONNECT method starts two-way communications with the requested resource.
    static final Method
    The DELETE method requests that the origin server delete the resource identified by the Request-URI.
    static final Method
    The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.
    static final Method
    The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.
    static final Method
    The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI.
    static final Method
    The PATCH method as described in RFC 5789 is used to perform an update to an existing resource, where the request payload only has to contain the instructions on how to perform the update.
    static final Method
    The POST method is used to request that the origin server acceptedTypes the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.
    static final Method
    The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
    static final Method
    The TRACE method is used to invoke a remote, application-layer loop- back of the request message.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Method
    create(String name)
    Create new HTTP request method instance from the provided name.
    boolean
     
    int
     
    int
    Number of characters.
    Deprecated.
    use text() instead, this method conflicts with enum
    predicate(Method... methods)
    Create a predicate for the provided methods.
    Create a predicate for the provided methods.
    Name of the method (such as GET or POST).
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • GET

      public static final Method GET
      The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the tryProcess.
    • POST

      public static final Method POST
      The POST method is used to request that the origin server acceptedTypes the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a database.
    • PUT

      public static final Method PUT
      The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.
    • DELETE

      public static final Method DELETE
      The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.
    • OPTIONS

      public static final Method OPTIONS
      The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.
    • TRACE

      public static final Method TRACE
      The TRACE method is used to invoke a remote, application-layer loop- back of the request message. The final recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK) response. The final recipient is either the origin server or the first proxy or gateway to receive a Max-Forwards value of zero (0) in the request (see section 14.31). A TRACE request MUST NOT include an entity.
    • PATCH

      public static final Method PATCH
      The PATCH method as described in RFC 5789 is used to perform an update to an existing resource, where the request payload only has to contain the instructions on how to perform the update. This is in contrast to PUT which requires that the payload contains the new version of the resource. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request.
    • CONNECT

      public static final Method CONNECT
      The HTTP CONNECT method starts two-way communications with the requested resource. It can be used to open a tunnel.
  • Method Details

    • create

      public static Method create(String name)
      Create new HTTP request method instance from the provided name.

      In case the method name is recognized as one of the standard HTTP methods, the respective enumeration value is returned.

      Parameters:
      name - the method name. Must not be null or empty and must be a legal HTTP method name string.
      Returns:
      HTTP request method instance representing an HTTP method with the provided name.
      Throws:
      IllegalArgumentException - In case of illegal method name or in case the name is empty or null.
    • predicate

      public static MethodPredicate predicate(Method... methods)
      Create a predicate for the provided methods.
      Parameters:
      methods - methods to check against
      Returns:
      a predicate that will validate the method is one of the methods provided; if methods are empty, the predicate will always return true
    • predicate

      public static MethodPredicate predicate(Collection<Method> methods)
      Create a predicate for the provided methods.
      Parameters:
      methods - methods to check against
      Returns:
      a predicate that will validate the method is one of the methods provided; if methods are empty, the predicate will always return true
    • name

      @Deprecated public String name()
      Deprecated.
      use text() instead, this method conflicts with enum
      Name of the method (such as GET or POST).
      Returns:
      a method name.
    • text

      public String text()
      Name of the method (such as GET or POST).
      Returns:
      a method name.
    • length

      public int length()
      Number of characters.
      Returns:
      number of characters of this method
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object