Interface HttpClient
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
AbstractAsyncOnlyHttpClient,ArmeriaHttpClient,JDKHttpClient,OkHttpHttpClient
public interface HttpClient extends Closeable
Interface définissant le contrat pour les clients HTTP utilisés par ScribeJava.Cette abstraction permet à la bibliothèque d'utiliser différentes implémentations réseau (JDK standard, OkHttp, Armeria, etc.) de manière transparente.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONTENT_LENGTHEn-tête HTTP Content-Length.static StringCONTENT_TYPEEn-tête HTTP Content-Type.static StringDEFAULT_CONTENT_TYPEType de contenu par défaut pour les requêtes OAuth.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Responseexecute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, byte[] bodyContents)Exécute une requête de manière synchrone avec un corps sous forme de tableau d'octets.Responseexecute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, MultipartPayload bodyContents)Exécute une requête de manière synchrone avec un corps multipart.Responseexecute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, File bodyContents)Exécute une requête de manière synchrone en envoyant un fichier.Responseexecute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, String bodyContents)Exécute une requête de manière synchrone avec un corps textuel.<T> CompletableFuture<T>executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, byte[] bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)Exécute une requête de manière asynchrone avec un corps sous forme de tableau d'octets.<T> CompletableFuture<T>executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, MultipartPayload bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)Exécute une requête de manière asynchrone avec un corps multipart.<T> CompletableFuture<T>executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, File bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)Exécute une requête de manière asynchrone en envoyant un fichier.<T> CompletableFuture<T>executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, String bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)Exécute une requête de manière asynchrone avec un corps textuel.
-
-
-
Field Detail
-
DEFAULT_CONTENT_TYPE
static final String DEFAULT_CONTENT_TYPE
Type de contenu par défaut pour les requêtes OAuth.- See Also:
- Constant Field Values
-
CONTENT_TYPE
static final String CONTENT_TYPE
En-tête HTTP Content-Type.- See Also:
- Constant Field Values
-
CONTENT_LENGTH
static final String CONTENT_LENGTH
En-tête HTTP Content-Length.- See Also:
- Constant Field Values
-
-
Method Detail
-
executeAsync
<T> CompletableFuture<T> executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, byte[] bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)
Exécute une requête de manière asynchrone avec un corps sous forme de tableau d'octets.- Type Parameters:
T- Type de l'objet retourné après conversion.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Contenu du corps.callback- Rappel optionnel.converter- Convertisseur de réponse.- Returns:
- Un
CompletableFuturede type T.
-
executeAsync
<T> CompletableFuture<T> executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, MultipartPayload bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)
Exécute une requête de manière asynchrone avec un corps multipart.- Type Parameters:
T- Type cible.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Charge utile multipart.callback- Rappel optionnel.converter- Convertisseur de réponse.- Returns:
- Un
CompletableFuture.
-
executeAsync
<T> CompletableFuture<T> executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, String bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)
Exécute une requête de manière asynchrone avec un corps textuel.- Type Parameters:
T- Type cible.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Contenu texte.callback- Rappel optionnel.converter- Convertisseur de réponse.- Returns:
- Un
CompletableFuture.
-
executeAsync
<T> CompletableFuture<T> executeAsync(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, File bodyContents, OAuthAsyncRequestCallback<T> callback, OAuthRequest.ResponseConverter<T> converter)
Exécute une requête de manière asynchrone en envoyant un fichier.- Type Parameters:
T- Type cible.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Fichier à envoyer.callback- Rappel optionnel.converter- Convertisseur de réponse.- Returns:
- Un
CompletableFuture.
-
execute
Response execute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, byte[] bodyContents) throws InterruptedException, ExecutionException, IOException
Exécute une requête de manière synchrone avec un corps sous forme de tableau d'octets.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Contenu du corps.- Returns:
- La réponse HTTP
Response. - Throws:
InterruptedException- si le thread est interrompu.ExecutionException- si la requête échoue.IOException- en cas d'erreur réseau.
-
execute
Response execute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, MultipartPayload bodyContents) throws InterruptedException, ExecutionException, IOException
Exécute une requête de manière synchrone avec un corps multipart.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Charge utile multipart.- Returns:
- La réponse HTTP.
- Throws:
InterruptedException- si interruption.ExecutionException- si échec.IOException- si erreur réseau.
-
execute
Response execute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, String bodyContents) throws InterruptedException, ExecutionException, IOException
Exécute une requête de manière synchrone avec un corps textuel.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Contenu texte.- Returns:
- La réponse HTTP.
- Throws:
InterruptedException- si interruption.ExecutionException- si échec.IOException- si erreur réseau.
-
execute
Response execute(String userAgent, Map<String,String> headers, Verb httpVerb, String completeUrl, File bodyContents) throws InterruptedException, ExecutionException, IOException
Exécute une requête de manière synchrone en envoyant un fichier.- Parameters:
userAgent- Chaîne User-Agent.headers- En-têtes HTTP.httpVerb- Verbe HTTP.completeUrl- URL complète.bodyContents- Fichier à envoyer.- Returns:
- La réponse HTTP.
- Throws:
InterruptedException- si interruption.ExecutionException- si échec.IOException- si erreur réseau.
-
-