use of org.wso2.transport.http.netty.message.Http2PushPromise in project ballerina by ballerina-lang.
the class GetPromisedResponse method execute.
@Override
public void execute(Context context, CallableUnitCallback callback) {
DataContext dataContext = new DataContext(context, callback);
BStruct pushPromiseStruct = (BStruct) context.getRefArgument(1);
Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, null);
if (http2PushPromise == null) {
throw new BallerinaException("invalid push promise");
}
BStruct bConnector = (BStruct) context.getRefArgument(0);
HttpClientConnector clientConnector = (HttpClientConnector) bConnector.getNativeData(HttpConstants.HTTP_CLIENT);
clientConnector.getPushResponse(http2PushPromise).setPushResponseListener(new PushResponseListener(dataContext), http2PushPromise.getPromisedStreamId());
}
use of org.wso2.transport.http.netty.message.Http2PushPromise in project ballerina by ballerina-lang.
the class Promise method execute.
@Override
public void execute(Context context) {
BStruct connectionStruct = (BStruct) context.getRefArgument(0);
HTTPCarbonMessage inboundRequestMsg = HttpUtil.getCarbonMsg(connectionStruct, null);
HttpUtil.serverConnectionStructCheck(inboundRequestMsg);
BStruct pushPromiseStruct = (BStruct) context.getRefArgument(1);
Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, HttpUtil.createHttpPushPromise(pushPromiseStruct));
HttpResponseFuture outboundRespStatusFuture = HttpUtil.pushPromise(inboundRequestMsg, http2PushPromise);
BValue[] outboundResponseStatus = handleResponseStatus(context, outboundRespStatusFuture);
context.setReturnValues(outboundResponseStatus);
}
use of org.wso2.transport.http.netty.message.Http2PushPromise in project ballerina by ballerina-lang.
the class PushPromisedResponse method execute.
@Override
public void execute(Context context) {
BStruct connectionStruct = (BStruct) context.getRefArgument(0);
HTTPCarbonMessage inboundRequestMsg = HttpUtil.getCarbonMsg(connectionStruct, null);
HttpUtil.serverConnectionStructCheck(inboundRequestMsg);
BStruct pushPromiseStruct = (BStruct) context.getRefArgument(1);
Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, null);
if (http2PushPromise == null) {
throw new BallerinaException("invalid push promise");
}
BStruct outboundResponseStruct = (BStruct) context.getRefArgument(2);
HTTPCarbonMessage outboundResponseMsg = HttpUtil.getCarbonMsg(outboundResponseStruct, HttpUtil.createHttpCarbonMessage(false));
HttpUtil.prepareOutboundResponse(context, inboundRequestMsg, outboundResponseMsg, outboundResponseStruct);
BValue[] outboundResponseStatus = pushResponseRobust(context, inboundRequestMsg, outboundResponseStruct, outboundResponseMsg, http2PushPromise);
context.setReturnValues(outboundResponseStatus);
}
use of org.wso2.transport.http.netty.message.Http2PushPromise in project ballerina by ballerina-lang.
the class PushPromisedResponse method pushResponseRobust.
private BValue[] pushResponseRobust(Context context, HTTPCarbonMessage requestMessage, BStruct outboundResponseStruct, HTTPCarbonMessage responseMessage, Http2PushPromise http2PushPromise) {
BStruct entityStruct = MimeUtil.extractEntity(outboundResponseStruct);
HttpResponseFuture outboundRespStatusFuture = HttpUtil.pushResponse(requestMessage, responseMessage, http2PushPromise);
if (entityStruct != null) {
MessageDataSource outboundMessageSource = EntityBodyHandler.getMessageDataSource(entityStruct);
serializeMsgDataSource(responseMessage, outboundMessageSource, outboundRespStatusFuture, entityStruct);
}
return handleResponseStatus(context, outboundRespStatusFuture);
}
use of org.wso2.transport.http.netty.message.Http2PushPromise in project ballerina by ballerina-lang.
the class GetHeader method execute.
@Override
public void execute(Context context) {
BStruct pushPromiseStruct = (BStruct) context.getRefArgument(0);
Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, HttpUtil.createHttpPushPromise(pushPromiseStruct));
String headerName = context.getStringArgument(0);
context.setReturnValues(new BString(http2PushPromise.getHeader(headerName)));
}
Aggregations