com.fireflysource.net.http.client.HttpClient Maven / Gradle / Ivy
package com.fireflysource.net.http.client;
import com.fireflysource.common.lifecycle.LifeCycle;
import com.fireflysource.net.http.common.model.HttpMethod;
import com.fireflysource.net.http.common.model.HttpURI;
import com.fireflysource.net.websocket.client.WebSocketClientConnectionBuilder;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* @author Pengtao Qiu
*/
public interface HttpClient extends LifeCycle {
/**
* Create a RequestBuilder with GET method and URL.
*
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder get(String url);
/**
* Create a RequestBuilder with POST method and URL.
*
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder post(String url);
/**
* Create a RequestBuilder with HEAD method and URL.
*
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder head(String url);
/**
* Create a RequestBuilder with PUT method and URL.
*
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder put(String url);
/**
* Create a RequestBuilder with DELETE method and URL.
*
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder delete(String url);
/**
* Create a RequestBuilder with HTTP method and URL.
*
* @param method The HTTP method.
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder request(HttpMethod method, String url);
/**
* Create a RequestBuilder with HTTP method and URL.
*
* @param method The HTTP method.
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder request(String method, String url);
/**
* Create a RequestBuilder with HTTP method and URL.
*
* @param method The HTTP method.
* @param url The request URL.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder request(String method, URL url);
/**
* Create a RequestBuilder with HTTP method and URL.
*
* @param method The HTTP method.
* @param httpURI The HTTP URI.
* @return A new RequestBuilder that helps you to build an HTTP request.
*/
HttpClientRequestBuilder request(String method, HttpURI httpURI);
/**
* Create a new HTTP client connection.
*
* @param httpURI The HTTP URI.
* @param supportedProtocols The supported application protocols.
* @return The new HTTP client connection.
*/
CompletableFuture createHttpClientConnection(HttpURI httpURI, List supportedProtocols);
/**
* Create a new HTTP client connection.
*
* @param httpURI The HTTP URI.
* @return The new HTTP client connection.
*/
default CompletableFuture createHttpClientConnection(HttpURI httpURI) {
return createHttpClientConnection(httpURI, Collections.emptyList());
}
/**
* Create a new HTTP client connection.
*
* @param uri The HTTP URI.
* @return The new HTTP client connection.
*/
default CompletableFuture createHttpClientConnection(String uri) {
return createHttpClientConnection(new HttpURI(uri));
}
/**
* Create a websocket connection builder.
*
* @return The websocket connection builder.
*/
WebSocketClientConnectionBuilder websocket();
/**
* Create a websocket connection builder.
*
* @param url The websocket url.
* @return The websocket connection builder.
*/
WebSocketClientConnectionBuilder websocket(String url);
}