本文整理汇总了Java中io.vertx.core.streams.ReadStream.handler方法的典型用法代码示例。如果您正苦于以下问题:Java ReadStream.handler方法的具体用法?Java ReadStream.handler怎么用?Java ReadStream.handler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.streams.ReadStream
的用法示例。
在下文中一共展示了ReadStream.handler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: myPermissionHandle
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
/**
* Simple test to fake a _tenantPermission interface.
* Captures the body, and reports it in a header.
*
* @param ctx
*/
private void myPermissionHandle(RoutingContext ctx) {
ReadStream<Buffer> content = ctx.request();
final Buffer incoming = Buffer.buffer();
content.handler(incoming::appendBuffer);
ctx.request().endHandler(x -> {
String body = incoming.toString();
body = body.replaceAll("\\s+", " "); // remove newlines etc
ctx.response().putHeader("X-Tenant-Perms-Result", body);
if (body.length() > 80) {
body = body.substring(0, 80) + "...";
}
logger.info("tenantPermissions: " + body);
ctx.response().end();
});
}
示例2: proxyRequestOnly
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestOnly(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
if (bcontent != null) {
proxyRequestHttpClient(it, pc, bcontent, mi);
} else {
final Buffer incoming = Buffer.buffer();
stream.handler(data -> {
incoming.appendBuffer(data);
pc.trace("ProxyRequestOnly request chunk '"
+ data.toString() + "'");
});
stream.endHandler(v -> {
pc.trace("ProxyRequestOnly request end");
proxyRequestHttpClient(it, pc, incoming, mi);
});
stream.resume();
}
}
示例3: proxyRequestResponse10
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestResponse10(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
if (bcontent != null) {
proxyRequestResponse(it, pc, null, bcontent, mi);
} else {
final Buffer incoming = Buffer.buffer();
stream.handler(data -> {
incoming.appendBuffer(data);
pc.trace("ProxyRequestBlock request chunk '"
+ data.toString() + "'");
});
stream.endHandler(v -> {
pc.trace("ProxyRequestBlock request end");
proxyRequestResponse(it, pc, null, incoming, mi);
});
stream.resume();
}
}
示例4: proxyInternal
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyInternal(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
pc.debug("proxyInternal " + mi.getModuleDescriptor().getId());
if (bcontent != null) {
proxyInternalBuffer(it, pc, bcontent, mi);
} else { // read the whole request into a buffer
final Buffer incoming = Buffer.buffer();
stream.handler(data -> {
incoming.appendBuffer(data);
pc.trace("proxyInternal request chunk '"
+ data.toString() + "'");
});
stream.endHandler(v -> {
pc.trace("proxyInternal request end");
proxyInternalBuffer(it, pc, incoming, mi);
});
stream.resume();
}
}
示例5: proxyRequestResponse
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestResponse(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
RoutingContext ctx = pc.getCtx();
HttpClientRequest cReq = httpClient.requestAbs(ctx.request().method(),
makeUrl(mi, ctx), res -> {
if (res.statusCode() >= 200 && res.statusCode() < 300
&& res.getHeader(XOkapiHeaders.STOP) == null
&& it.hasNext()) {
makeTraceHeader(mi, res.statusCode(), pc);
relayToRequest(res, pc);
res.pause();
proxyR(it, pc, res, null);
} else {
relayToResponse(ctx.response(), res);
makeTraceHeader(mi, res.statusCode(), pc);
res.handler(data -> {
ctx.response().write(data);
pc.trace("ProxyRequestResponse response chunk '"
+ data.toString() + "'");
});
res.endHandler(v -> {
pc.closeTimer();
ctx.response().end();
pc.trace("ProxyRequestResponse response end");
});
res.exceptionHandler(e
-> pc.warn("proxyRequestResponse: res exception ", e));
}
});
cReq.exceptionHandler(e -> {
pc.warn("proxyRequestResponse failure: ", e);
pc.responseText(500, "proxyRequestResponse failure: "
+ mi.getModuleDescriptor().getId() + " " + mi.getUrl() + ": "
+ e + " " + e.getMessage());
});
cReq.headers().setAll(ctx.request().headers());
cReq.headers().remove("Content-Length");
if (bcontent != null) {
pc.trace("proxyRequestResponse request buf '" + bcontent + "'");
cReq.end(bcontent);
} else {
cReq.setChunked(true);
stream.handler(data -> {
pc.trace("proxyRequestResponse request chunk '"
+ data.toString() + "'");
cReq.write(data);
});
stream.endHandler(v -> {
pc.trace("proxyRequestResponse request complete");
cReq.end();
});
stream.exceptionHandler(e
-> pc.warn("proxyRequestResponse: content exception ", e));
stream.resume();
}
log(pc, cReq);
}