本文整理汇总了Java中org.asynchttpclient.Request.getStringData方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getStringData方法的具体用法?Java Request.getStringData怎么用?Java Request.getStringData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.asynchttpclient.Request
的用法示例。
在下文中一共展示了Request.getStringData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recordNonMultipartData
import org.asynchttpclient.Request; //导入方法依赖的package包/类
/**
* <pre>
* Body could be String, byte array, Stream or EntityWriter.
* We collect String data only.
* </pre>
*
* @param httpRequest
* @param recorder
*/
protected void recordNonMultipartData(final Request httpRequest, final SpanEventRecorder recorder) {
final String stringData = httpRequest.getStringData();
if (stringData != null) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, StringUtils.abbreviate(stringData, config.getEntityDumpSize()));
return;
}
final byte[] byteData = httpRequest.getByteData();
if (byteData != null) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, "BYTE_DATA");
return;
}
final InputStream streamData = httpRequest.getStreamData();
if (streamData != null) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, "STREAM_DATA");
return;
}
}
示例2: submit
import org.asynchttpclient.Request; //导入方法依赖的package包/类
private <T> ListenableFuture<T> submit(Request request, ZendeskAsyncCompletionHandler<T> handler) {
if (logger.isDebugEnabled()) {
if (request.getStringData() != null) {
logger.debug("Request {} {}\n{}", request.getMethod(), request.getUrl(), request.getStringData());
} else if (request.getByteData() != null) {
logger.debug("Request {} {} {} {} bytes", request.getMethod(), request.getUrl(),
request.getHeaders().get("Content-type"), request.getByteData().length);
} else {
logger.debug("Request {} {}", request.getMethod(), request.getUrl());
}
}
return client.executeRequest(request, handler);
}
示例3: body
import org.asynchttpclient.Request; //导入方法依赖的package包/类
private NettyBody body(Request request, boolean connect) {
NettyBody nettyBody = null;
if (!connect) {
Charset bodyCharset = withDefault(request.getCharset(), DEFAULT_CHARSET);
if (request.getByteData() != null)
nettyBody = new NettyByteArrayBody(request.getByteData());
else if (request.getCompositeByteData() != null)
nettyBody = new NettyCompositeByteArrayBody(request.getCompositeByteData());
else if (request.getStringData() != null)
nettyBody = new NettyByteBufferBody(StringUtils.charSequence2ByteBuffer(request.getStringData(), bodyCharset));
else if (request.getByteBufferData() != null)
nettyBody = new NettyByteBufferBody(request.getByteBufferData());
else if (request.getStreamData() != null)
nettyBody = new NettyInputStreamBody(request.getStreamData());
else if (isNonEmpty(request.getFormParams())) {
String contentType = null;
if (!request.getHeaders().contains(CONTENT_TYPE))
contentType = HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED;
nettyBody = new NettyByteBufferBody(urlEncodeFormParams(request.getFormParams(), bodyCharset), contentType);
} else if (isNonEmpty(request.getBodyParts()))
nettyBody = new NettyMultipartBody(request.getBodyParts(), request.getHeaders(), config);
else if (request.getFile() != null)
nettyBody = new NettyFileBody(request.getFile(), config);
else if (request.getBodyGenerator() instanceof FileBodyGenerator) {
FileBodyGenerator fileBodyGenerator = (FileBodyGenerator) request.getBodyGenerator();
nettyBody = new NettyFileBody(fileBodyGenerator.getFile(), fileBodyGenerator.getRegionSeek(), fileBodyGenerator.getRegionLength(), config);
} else if (request.getBodyGenerator() instanceof InputStreamBodyGenerator)
nettyBody = new NettyInputStreamBody(InputStreamBodyGenerator.class.cast(request.getBodyGenerator()).getInputStream());
else if (request.getBodyGenerator() instanceof ReactiveStreamsBodyGenerator)
nettyBody = new NettyReactiveStreamsBody(ReactiveStreamsBodyGenerator.class.cast(request.getBodyGenerator()).getPublisher());
else if (request.getBodyGenerator() != null)
nettyBody = new NettyBodyBody(request.getBodyGenerator().createBody(), config);
}
return nettyBody;
}