Class Method
java.lang.Object
org.apache.tomcat.util.http.Method
HTTP method constants and utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCONNECT method.static final StringCOPY method.static final StringDELETE method.static final StringGET method.static final StringHEAD method.static final StringLOCK method.static final StringMKCOL method.static final StringMOVE method.static final StringOPTIONS method.static final StringPATCH method.static final StringPOST method.static final StringPROPFIND method.static final StringPROPPATCH method.static final StringPUT method.static final StringTRACE method.static final StringUNLOCK method. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbytesToString(byte[] buf, int start, int len) Provides optimised conversion from bytes to Strings for known HTTP methods.
-
Field Details
-
GET
-
POST
-
PUT
-
PATCH
-
HEAD
-
OPTIONS
-
DELETE
-
TRACE
-
PROPFIND
-
PROPPATCH
-
MKCOL
-
COPY
-
MOVE
-
LOCK
-
UNLOCK
-
CONNECT
-
-
Method Details
-
bytesToString
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 convertstart- The first byte of the HTTP methodlen- The number of bytes to convert- Returns:
- The HTTP method as a String or
nullif the method is not recognised.
-