Class HttpProtocolHandler
java.lang.Object
com.thecsdev.common.resource.protocol.HttpProtocolHandler
- All Implemented Interfaces:
ProtocolHandler
A
ProtocolHandler implementation for handling "http" and "https" protocol
URIs. This handler processes HTTP and HTTPS requests and returns their
responses as ResourceResponse objects.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe HTTP header key used to specify the HTTP method (e.g., GET, POST, PUT, DELETE) for the request.static final HttpProtocolHandlerThe main singleton instance ofHttpProtocolHandler.static final intA general I/O failure or error occurred while accessing the file.static final intAccess denied; the system refused to open the file due to insufficient permissions.static final intThe specified path does not exist or the file is missing.static final intResource found and read successfully from the filesystem. -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull CompletableFuture<ResourceResponse> handle(@NotNull ResourceRequest rssReq) Handles the givenResourceRequestand returns aCompletableFuturethat will complete with aResourceResponse.final booleanDetermines if thisProtocolHandlercan handle the givenURI.
-
Field Details
-
INSTANCE
The main singleton instance ofHttpProtocolHandler. -
HEADER_HTTP_METHOD
The HTTP header key used to specify the HTTP method (e.g., GET, POST, PUT, DELETE) for the request. If not provided, the default method is "GET".- See Also:
-
STATUS_OK
public static final int STATUS_OKResource found and read successfully from the filesystem.- See Also:
-
STATUS_FORBIDDEN
public static final int STATUS_FORBIDDENAccess denied; the system refused to open the file due to insufficient permissions.- See Also:
-
STATUS_NOT_FOUND
public static final int STATUS_NOT_FOUNDThe specified path does not exist or the file is missing.- See Also:
-
STATUS_ERROR
public static final int STATUS_ERRORA general I/O failure or error occurred while accessing the file.- See Also:
-
-
Method Details
-
matches
Description copied from interface:ProtocolHandlerDetermines if thisProtocolHandlercan handle the givenURI.- Specified by:
matchesin interfaceProtocolHandler- Parameters:
uri- The URI to check.- Returns:
trueif this handler can process the URI;falseotherwise.
-
handle
@NotNull public final @NotNull CompletableFuture<ResourceResponse> handle(@NotNull @NotNull ResourceRequest rssReq) throws NullPointerException, IllegalArgumentException Description copied from interface:ProtocolHandlerHandles the givenResourceRequestand returns aCompletableFuturethat will complete with aResourceResponse.- Specified by:
handlein interfaceProtocolHandler- Parameters:
rssReq- TheResourceRequestto handle.- Throws:
NullPointerException- If the argument isnull.IllegalArgumentException- IfURI.getScheme()of theResourceMessage.getUri()is unsupported.
-