Method (Apache Tomcat 9.0.111 API Documentation)
Description: declaration: package: org.apache.tomcat.util.http, class: Method

# Class Method

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

public class Method extends Object

- ## Field Summary

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

- ## 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
    See Also:
      - Constant Field Values

  - ### POST

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

  - ### PUT

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

  - ### PATCH

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

  - ### HEAD

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

  - ### OPTIONS

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

  - ### DELETE

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

  - ### TRACE

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

  - ### PROPFIND

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

  - ### PROPPATCH

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

  - ### MKCOL

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

  - ### COPY

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

  - ### MOVE

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

  - ### LOCK

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

  - ### UNLOCK

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

  - ### CONNECT

    public static final String CONNECT
    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.