Enum Class HTTPMethode
- All Implemented Interfaces:
Serializable, Comparable<HTTPMethode>, Constable
This enum defines the standard HTTP methods as specified in RFC 7231 (HTTP/1.1) and RFC 5789 (PATCH). Each method has a specific semantic meaning that defines the intent of the request operation.
HTTP methods are used to indicate the desired action to be performed on the identified resource. The method determines how the server should process the request and what type of response to generate.
Method properties:
- Safe methods: GET, HEAD, OPTIONS - Read-only operations that don't modify server state
- Idempotent methods: GET, HEAD, PUT, DELETE, OPTIONS - Multiple identical requests have the same effect as a single request
- Cacheable methods: GET, HEAD, POST - Responses may be cached by clients or proxies
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDELETE method - Deletes the specified resource.GET method - Retrieves a representation of the specified resource.HEAD method - Retrieves the headers for a resource without the response body.OPTIONS method - Describes the communication options for the target resource.POST method - Submits data to be processed by the specified resource.PUT method - Replaces all current representations of the target resource with the request payload. -
Method Summary
Modifier and TypeMethodDescriptionstatic HTTPMethodeReturns the enum constant of this class with the specified name.static HTTPMethode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GET
GET method - Retrieves a representation of the specified resource.The GET method requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect on the server state.
Characteristics:
- Safe: Yes (read-only operation)
- Idempotent: Yes (multiple requests return the same result)
- Cacheable: Yes
- Request has body: No (typically)
- Response has body: Yes
Common use cases: Fetching web pages, retrieving API resources, downloading files
-
POST
POST method - Submits data to be processed by the specified resource.The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server. This is commonly used for creating new resources, submitting form data, or triggering server-side operations.
Characteristics:
- Safe: No (modifies server state)
- Idempotent: No (multiple requests may have different effects)
- Cacheable: Yes (with appropriate headers)
- Request has body: Yes
- Response has body: Yes
Common use cases: Creating new resources, submitting forms, uploading files, processing payments
-
PUT
PUT method - Replaces all current representations of the target resource with the request payload.The PUT method replaces the entire target resource with the provided representation. If the resource doesn't exist, it may be created. PUT is typically used for updates where the entire resource is replaced.
Characteristics:
- Safe: No (modifies server state)
- Idempotent: Yes (multiple identical requests result in the same state)
- Cacheable: No
- Request has body: Yes
- Response has body: Typically no (may return success status)
Common use cases: Updating existing resources, replacing entire entities, uploading files to specific URLs
-
DELETE
DELETE method - Deletes the specified resource.The DELETE method removes the specified resource from the server. Multiple identical DELETE requests should have the same effect as a single request (idempotent).
Characteristics:
- Safe: No (modifies server state)
- Idempotent: Yes (deleting a resource multiple times results in the same state)
- Cacheable: No
- Request has body: May have (not typical)
- Response has body: May have (typically status confirmation)
Common use cases: Removing resources, deleting database records, cleaning up temporary files
-
HEAD
HEAD method - Retrieves the headers for a resource without the response body.The HEAD method is identical to GET except that the server must not return a message body in the response. It's used to obtain metadata about a resource without transferring its entire representation.
Characteristics:
- Safe: Yes (read-only operation)
- Idempotent: Yes (multiple requests return the same headers)
- Cacheable: Yes
- Request has body: No
- Response has body: No (headers only)
Common use cases: Checking if a resource exists, retrieving metadata (size, type, last-modified), testing for broken links, caching validation
-
OPTIONS
OPTIONS method - Describes the communication options for the target resource.The OPTIONS method requests information about the communication options available for the target resource. This is commonly used to discover which HTTP methods are supported by the server for a specific resource (indicated by the Allow header).
Characteristics:
- Safe: Yes (read-only operation)
- Idempotent: Yes (multiple requests return the same options)
- Cacheable: No
- Request has body: No
- Response has body: Typically minimal (may describe options)
Common use cases: CORS preflight requests, discovering supported methods, API capability discovery
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-