Response Handler Utility
Provides methods for processing HTTP responses in various formats.
Features
- Response to text conversion
- Response to JSON/XML conversion
- File download handling
- GZip response handling
- Detailed logging
Usage Examples
// Convert response to JSON
Map<String, Object> json = ResponseHandler.toJson(response);
// Convert response to XML
Map<String, String> xml = ResponseHandler.toXML(response);
// Download file from response
String filePath = ResponseHandler.download(response, "/downloads", "file.pdf");
Connection Setup Utility
Provides common configurations for HTTP connections.
Features
- Cookie handling
- Referer setting
- Timeout configuration
- User-Agent configuration
- GZip support
- Header mapping
Usage Examples
// Set custom User-Agent
connectionConsumer = SetConnection.SET_USER_AGENT.andThen(conn -> conn.setRequestProperty("User-Agent", "MyApp/1.0"));
// Set cookies
Map<String, String> cookies = ObjectHelper.mapOf("session", "12345");
SetConnection.SET_COOKIES.accept(connection, cookies);
Batch Download Utility
Provides concurrent downloading of multiple files.
Features
- Concurrent downloads using multiple threads
- Customizable file naming
- Progress tracking via CountDownLatch
Usage Examples
String[] urls = {
"https://example.com/file1.pdf",
"https://example.com/file2.pdf"
};
BatchDownload downloader = new BatchDownload(urls, "/downloads",
() -> "custom_" + System.currentTimeMillis());
downloader.start();
String[] downloadedNames = downloader.getFileNames();
The input URL array is copied and is never overwritten. Result names are stored separately and use
Path.getFileName(), so Unix and Windows paths are handled consistently.
Multipart file upload
FileUpload.upload(...) creates a random boundary for every request, encodes headers and text fields as UTF-8,
and streams File values to the connection. Empty multipart maps and invalid field names are rejected explicitly;
null field values are serialized as empty text fields. writeFormData(...) exposes the same streaming encoder for
custom transports.
Head.gzip(...) returns the original stream when the response is not gzip encoded. Invalid gzip content causes
UncheckedIOException with the original IOException as its cause.
SSL Certificate Utility
Provides methods for handling SSL certificate verification.
Features
- Skip SSL certificate verification
- Custom certificate loading
- Global SSL context configuration
Usage Examples
// Skip SSL verification globally
SkipSSL.init();
// Skip SSL verification for single connection
SkipSSL.setSSL_Ignore((HttpsURLConnection)connection);
// Load custom certificate
KeyManager[] kms = SkipSSL.loadCert("/path/to/cert.p12", "password");
SSLSocketFactory sf = SkipSSL.getSocketFactory(kms);