Package org.dmfs.httpessentials
Interface HttpMethod
- All Known Implementing Classes:
AbstractMethod,IdempotentMethod,Method,SafeMethod
public interface HttpMethod
Represents an HTTP method and provides static members for HTTP methods defined in RFC 7231, section
4.3 and RFC 5789
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpMethodHTTP Method CONNECTstatic final HttpMethodHTTP Method DELETEstatic final HttpMethodHTTP Method GETstatic final HttpMethodHTTP Method HEADstatic final HttpMethodHTTP Method OPTIONSstatic final HttpMethodHTTP Method PATCHstatic final HttpMethodHTTP Method POSTstatic final HttpMethodHTTP Method PUTstatic final HttpMethodHTTP Method TRACE -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns if this request method is idempotent, which means that sending multiple identical requests with that method has the same effect as sending one single request to the server.booleanisSafe()Returns if this request method is safe, which means that the request is not intended and not expected to change any state on the server.booleanReturns whether thisHttpMethodallows to send a message body.verb()Returns the HTTP verb of this method.
-
Field Details
-
GET
HTTP Method GET- See Also:
-
HEAD
HTTP Method HEAD- See Also:
-
POST
HTTP Method POST- See Also:
-
PUT
HTTP Method PUT- See Also:
-
DELETE
HTTP Method DELETE- See Also:
-
CONNECT
HTTP Method CONNECT- See Also:
-
OPTIONS
HTTP Method OPTIONS- See Also:
-
TRACE
HTTP Method TRACE- See Also:
-
PATCH
HTTP Method PATCH- See Also:
-
-
Method Details
-
verb
String verb()Returns the HTTP verb of this method.- Returns:
- A String containing the verb of the method.
-
isSafe
boolean isSafe()Returns if this request method is safe, which means that the request is not intended and not expected to change any state on the server. In effect the semantics are to be considered read-only.- See Also:
-
isIdempotent
boolean isIdempotent()Returns if this request method is idempotent, which means that sending multiple identical requests with that method has the same effect as sending one single request to the server.- See Also:
-
supportsRequestPayload
boolean supportsRequestPayload()Returns whether thisHttpMethodallows to send a message body.Note that RFC 7231 does not explicitly forbid a message payload for some methods (in particular these are
GET,HEAD,DELETEandCONNECT). Instead is says something like this:A payload within a XXX request message has no defined semantics; sending a payload body on a XXX request might cause some existing implementations to reject the request.
The predefined methods in
HttpMethodinterpret this rather strict and returnfalsefor such methods.- Returns:
trueif this method supports a message body,falseotherwise.
-