public final class ContentPreviewingClient extends SimpleDecoratingHttpClient
HttpClient to preview the content of Requests and Responses.
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.
...
});
| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
execute(ClientRequestContext ctx,
HttpRequest req)
|
static Function<? super HttpClient,ContentPreviewingClient> |
newDecorator(ContentPreviewerFactory contentPreviewerFactory)
Creates a new
ContentPreviewingClient decorator with the specified
ContentPreviewerFactory. |
static Function<? super HttpClient,ContentPreviewingClient> |
newDecorator(int maxLength)
Creates a new
ContentPreviewingClient decorator which produces text preview with the
specified maxLength limit. |
static Function<? super HttpClient,ContentPreviewingClient> |
newDecorator(int maxLength,
Charset defaultCharset)
Creates a new
ContentPreviewingClient decorator which produces text preview with the
specified maxLength limit. |
as, delegate, toStringpublic static Function<? super HttpClient,ContentPreviewingClient> newDecorator(int maxLength)
ContentPreviewingClient decorator which produces text preview with the
specified maxLength limit. The preview is produced when the content type of the
RequestHeaders or ResponseHeaders meets any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"maxLength - the maximum length of the previewpublic static Function<? super HttpClient,ContentPreviewingClient> newDecorator(int maxLength, Charset defaultCharset)
ContentPreviewingClient decorator which produces text preview with the
specified maxLength limit. The preview is produced when the content type of the
RequestHeaders or ResponseHeaders meets any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"maxLength - the maximum length of the previewdefaultCharset - the default charset used when a charset is not specified in the
"content-type" headerpublic static Function<? super HttpClient,ContentPreviewingClient> newDecorator(ContentPreviewerFactory contentPreviewerFactory)
ContentPreviewingClient decorator with the specified
ContentPreviewerFactory.public HttpResponse execute(ClientRequestContext ctx, HttpRequest req) throws Exception
ClientCopyright © 2020 LeanCloud. All rights reserved.