Class Method


  • public class Method
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONNECT  
      static java.lang.String COPY  
      static java.lang.String DELETE  
      static java.lang.String GET  
      static java.lang.String HEAD  
      static java.lang.String LOCK  
      static java.lang.String MKCOL  
      static java.lang.String MOVE  
      static java.lang.String OPTIONS  
      static java.lang.String PATCH  
      static java.lang.String POST  
      static java.lang.String PROPFIND  
      static java.lang.String PROPPATCH  
      static java.lang.String PUT  
      static java.lang.String TRACE  
      static java.lang.String UNLOCK  
    • 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.