Module de.cuioss.http
Package de.cuioss.http.client.handler
@NullMarked
package de.cuioss.http.client.handler
Secure HTTP client utilities and SSL/TLS context management for enterprise applications.
This package provides comprehensive HTTP client handling utilities with security-first design, offering simplified request execution, SSL/TLS context management, and HTTP status code classification. All components are designed for enterprise use with proper error handling, security defaults, and thread-safe operation.
Key Components
HttpHandler- Builder-based HTTP client with secure SSL defaultsHttpStatusFamily- RFC 7231 compliant HTTP status code categorizationSecureSSLContextProvider- TLS 1.2+ SSL context provider
Best Practices
- Always use HttpHandler.builder() - Provides secure defaults and validation
- Set appropriate timeouts - Prevent resource exhaustion with connection/read timeouts
- Use HttpStatusFamily for response handling - Type-safe status code classification
- Let SSL context auto-creation work - Secure defaults unless custom context needed
- Handle exceptions properly - IOException for network errors, InterruptedException for interruption
Usage Example
// Secure HTTPS client with auto-generated SSL context
HttpHandler handler = HttpHandler.builder()
.uri("https://api.example.com/data")
.connectionTimeoutSeconds(10)
.readTimeoutSeconds(30)
.build();
// Execute request with proper error handling
try {
HttpResponse<String> response = handler.executeGetRequest();
if (HttpStatusFamily.isSuccess(response.statusCode())) {
processData(response.body());
} else if (HttpStatusFamily.isClientError(response.statusCode())) {
handleClientError(response);
}
} catch (IOException e) {
log.error("Network error during HTTP request", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.warn("HTTP request interrupted");
}
Cross-References
- de.cuioss.http.security - HTTP security validation components
SSLContext- Java SSL context APIHttpClient- Java HTTP client API
Package Nullability
This package follows strict nullability conventions using JSpecify annotations:
- All parameters and return values are non-null by default
- Nullable parameters and return values are explicitly annotated with
@Nullable
- Since:
- 1.0
- Author:
- CUI HTTP Security Team
-
ClassDescriptionSecure HTTP client wrapper providing simplified HTTP request execution with robust SSL handling.Builder for creating
HttpHandlerinstances.HTTP status code classification enum based on RFC 7231 status code families.Provider for secure SSL contexts used in HTTPS communications.