Class ContentPreviewingClient
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Client<T_I,T_O>>
com.linecorp.armeria.client.DecoratingClient<I,O,I,O>
com.linecorp.armeria.client.SimpleDecoratingClient<HttpRequest,HttpResponse>
com.linecorp.armeria.client.SimpleDecoratingHttpClient
com.linecorp.armeria.client.logging.ContentPreviewingClient
- All Implemented Interfaces:
Client<HttpRequest,HttpResponse>
,HttpClient
,Unwrappable
public final class ContentPreviewingClient extends SimpleDecoratingHttpClient
Decorates an
HttpClient
to preview the content of Request
s and Response
s.
Note that this decorator just sets RequestOnlyLog.requestContentPreview()
and
RequestLog.responseContentPreview()
. You can get the previews using RequestLogAccess
.
RequestLogAccess logAccess = ctx.log();
logAccess.whenComplete().thenApply(log -> {
// Call log.requestContentPreview() and log.responseContentPreview() to use them.
...
});
-
Method Summary
Modifier and Type Method Description HttpResponse
execute(ClientRequestContext ctx, HttpRequest req)
static Function<? super HttpClient,ContentPreviewingClient>
newDecorator(int maxLength)
Creates a newContentPreviewingClient
decorator which produces text preview with the specifiedmaxLength
limit.static Function<? super HttpClient,ContentPreviewingClient>
newDecorator(int maxLength, Charset defaultCharset)
Creates a newContentPreviewingClient
decorator which produces text preview with the specifiedmaxLength
limit.static Function<? super HttpClient,ContentPreviewingClient>
newDecorator(ContentPreviewerFactory contentPreviewerFactory)
Creates a newContentPreviewingClient
decorator with the specifiedContentPreviewerFactory
.Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap
-
Method Details
-
newDecorator
Creates a newContentPreviewingClient
decorator which produces text preview with the specifiedmaxLength
limit. The preview is produced when the content type of theRequestHeaders
orResponseHeaders
meets any of the following conditions:- when it matches
text/*
orapplication/x-www-form-urlencoded
- when its charset has been specified
- when its subtype is
"xml"
or"json"
- when its subtype ends with
"+xml"
or"+json"
- Parameters:
maxLength
- the maximum length of the preview
- when it matches
-
newDecorator
public static Function<? super HttpClient,ContentPreviewingClient> newDecorator(int maxLength, Charset defaultCharset)Creates a newContentPreviewingClient
decorator which produces text preview with the specifiedmaxLength
limit. The preview is produced when the content type of theRequestHeaders
orResponseHeaders
meets any of the following conditions:- when it matches
text/*
orapplication/x-www-form-urlencoded
- when its charset has been specified
- when its subtype is
"xml"
or"json"
- when its subtype ends with
"+xml"
or"+json"
- Parameters:
maxLength
- the maximum length of the previewdefaultCharset
- the default charset used when a charset is not specified in the"content-type"
header
- when it matches
-
newDecorator
public static Function<? super HttpClient,ContentPreviewingClient> newDecorator(ContentPreviewerFactory contentPreviewerFactory)Creates a newContentPreviewingClient
decorator with the specifiedContentPreviewerFactory
. -
execute
Description copied from interface:Client
-