# Class Method

java.lang.Object
org.apache.tomcat.util.http.Method

public class Method extends Object
HTTP method constants and utilities.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CONNECT`
  CONNECT method.
  `static final String`
  `COPY`
  COPY method.
  `static final String`
  `DELETE`
  DELETE method.
  `static final String`
  `GET`
  GET method.
  `static final String`
  `HEAD`
  HEAD method.
  `static final String`
  `LOCK`
  LOCK method.
  `static final String`
  `MKCOL`
  MKCOL method.
  `static final String`
  `MOVE`
  MOVE method.
  `static final String`
  `OPTIONS`
  OPTIONS method.
  `static final String`
  `PATCH`
  PATCH method.
  `static final String`
  `POST`
  POST method.
  `static final String`
  `PROPFIND`
  PROPFIND method.
  `static final String`
  `PROPPATCH`
  PROPPATCH method.
  `static final String`
  `PUT`
  PUT method.
  `static final String`
  `TRACE`
  TRACE method.
  `static final String`
  `UNLOCK`
  UNLOCK method.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `bytesToString(byte[] buf, int start, int len)`
  Provides optimised conversion from bytes to Strings for known HTTP methods.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### GET

    public static final String GET
    GET method.
    See Also:
      - Constant Field Values

  - ### POST

    public static final String POST
    POST method.
    See Also:
      - Constant Field Values

  - ### PUT

    public static final String PUT
    PUT method.
    See Also:
      - Constant Field Values

  - ### PATCH

    public static final String PATCH
    PATCH method.
    See Also:
      - Constant Field Values

  - ### HEAD

    public static final String HEAD
    HEAD method.
    See Also:
      - Constant Field Values

  - ### OPTIONS

    public static final String OPTIONS
    OPTIONS method.
    See Also:
      - Constant Field Values

  - ### DELETE

    public static final String DELETE
    DELETE method.
    See Also:
      - Constant Field Values

  - ### TRACE

    public static final String TRACE
    TRACE method.
    See Also:
      - Constant Field Values

  - ### PROPFIND

    public static final String PROPFIND
    PROPFIND method.
    See Also:
      - Constant Field Values

  - ### PROPPATCH

    public static final String PROPPATCH
    PROPPATCH method.
    See Also:
      - Constant Field Values

  - ### MKCOL

    public static final String MKCOL
    MKCOL method.
    See Also:
      - Constant Field Values

  - ### COPY

    public static final String COPY
    COPY method.
    See Also:
      - Constant Field Values

  - ### MOVE

    public static final String MOVE
    MOVE method.
    See Also:
      - Constant Field Values

  - ### LOCK

    public static final String LOCK
    LOCK method.
    See Also:
      - Constant Field Values

  - ### UNLOCK

    public static final String UNLOCK
    UNLOCK method.
    See Also:
      - Constant Field Values

  - ### CONNECT

    public static final String CONNECT
    CONNECT method.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### bytesToString

    public static String bytesToString(byte[] buf, int start, int len)
    Provides optimised conversion from bytes to Strings for known HTTP methods. The bytes are assumed to be an ISO-8859-1 encoded representation of an HTTP method. The method is not validated as being a token, but only valid HTTP method names will be returned.

    Doing it this way is ~10x faster than using MessageBytes.toStringType() saving ~40ns per request which is ~1% of the processing time for a minimal "Hello World" type servlet. For non-standard methods there is an additional overhead of ~2.5ns per request.

    Pretty much every request ends up converting the method to a String so it is more efficient to do this straight away and always use Strings.

    Parameters:
      `buf` - The byte buffer containing the HTTP method to convert
      `start` - The first byte of the HTTP method
      `len` - The number of bytes to convert
    Returns:
      The HTTP method as a String or `null` if the method is not recognised.