use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class Level8NotifyClntListeners method sendRstToApp.
@Override
public XFuture<Void> sendRstToApp(Stream stream, CancelReason payload) {
if (stream instanceof ClientStream) {
ClientStream str = (ClientStream) stream;
ResponseStreamHandle handler = str.getResponseListener();
return handler.cancel(payload);
}
ClientPushStream str = (ClientPushStream) stream;
PushStreamHandle handle = str.getPushStreamHandle();
return handle.cancelPush(payload);
}
use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class DefaultCorsProcessor method send403Response.
private void send403Response(ResponseStreamHandle responseStream, Http2Request request) {
Http2Response response = new Http2Response();
response.addHeader(new Http2Header(Http2HeaderName.STATUS, "403"));
response.addHeader(new Http2Header(Http2HeaderName.VARY, "Origin"));
sendResponse(responseStream, response);
}
use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class JsonController method streaming.
public StreamRef streaming(ResponseStreamHandle handle) {
XFuture<StreamRef> futureStream = new XFuture<>();
XFuture<Boolean> authFuture = svc.authenticate("bobsmith");
XFuture<StreamWriter> writer = authFuture.thenCompose(resp -> {
StreamRef streamRef = client.stream(handle);
futureStream.complete(streamRef);
return streamRef.getWriter();
});
return new StreamRefProxy(writer, futureStream);
}
use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class ClientAsync method startWriteThread.
private Void startWriteThread(Http2Socket socket, int i, ResponseStreamHandle handler) {
Thread t = new Thread(new Writer(socket, handler));
t.setName("clientWriter" + i);
t.start();
return null;
}
use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class ClientAsync method runAsyncClient.
public void runAsyncClient(InetSocketAddress svrAddress) {
ResponseStreamHandle responseListener = new ResponseCounterListener();
log.error("ASYNC " + protocol + " CLIENT: logging will log every 10 seconds as ERROR so it shows up in red");
log.info("info messages automatically show up in black");
List<Http2Socket> sockets = new ArrayList<>();
for (int i = 0; i < config.getNumSockets(); i++) {
try {
log.info("connecting socket num=" + i);
Http2Socket socket = client.createHttpSocket(new CloseListener());
XFuture<Void> connect = socket.connect(svrAddress);
connect.get(2, TimeUnit.SECONDS);
sockets.add(socket);
} catch (Throwable e) {
throw SneakyThrow.sneak(e);
}
}
for (int i = 0; i < config.getNumSockets(); i++) {
Http2Socket socket = sockets.get(i);
startWriteThread(socket, i, responseListener);
}
}
Aggregations