Class Method


  • public class Method
    extends java.lang.Object
    HTTP method constants and utilities.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONNECT
      CONNECT method.
      static java.lang.String COPY
      COPY method.
      static java.lang.String DELETE
      DELETE method.
      static java.lang.String GET
      GET method.
      static java.lang.String HEAD
      HEAD method.
      static java.lang.String LOCK
      LOCK method.
      static java.lang.String MKCOL
      MKCOL method.
      static java.lang.String MOVE
      MOVE method.
      static java.lang.String OPTIONS
      OPTIONS method.
      static java.lang.String PATCH
      PATCH method.
      static java.lang.String POST
      POST method.
      static java.lang.String PROPFIND
      PROPFIND method.
      static java.lang.String PROPPATCH
      PROPPATCH method.
      static java.lang.String PUT
      PUT method.
      static java.lang.String TRACE
      TRACE method.
      static java.lang.String UNLOCK
      UNLOCK method.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String bytesToString​(byte[] buf, int start, int len)
      Provides optimised conversion from bytes to Strings for known HTTP methods.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • bytesToString

        public static java.lang.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.