Search in sources :

Example 1 with ResponseHandle

use of org.wso2.transport.http.netty.message.ResponseHandle in project ballerina by ballerina-lang.

the class GetResponse method execute.

@Override
public void execute(Context context, CallableUnitCallback callback) {
    DataContext dataContext = new DataContext(context, callback);
    BStruct handleStruct = ((BStruct) context.getRefArgument(1));
    ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE);
    if (responseHandle == null) {
        throw new BallerinaException("invalid http handle");
    }
    BStruct bConnector = (BStruct) context.getRefArgument(0);
    HttpClientConnector clientConnector = (HttpClientConnector) bConnector.getNativeData(HttpConstants.HTTP_CLIENT);
    clientConnector.getResponse(responseHandle).setHttpConnectorListener(new ResponseListener(dataContext));
}
Also used : DataContext(org.ballerinalang.net.http.DataContext) BStruct(org.ballerinalang.model.values.BStruct) ResponseHandle(org.wso2.transport.http.netty.message.ResponseHandle) HttpClientConnector(org.wso2.transport.http.netty.contract.HttpClientConnector) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Example 2 with ResponseHandle

use of org.wso2.transport.http.netty.message.ResponseHandle in project ballerina by ballerina-lang.

the class HasPromise method execute.

@Override
public void execute(Context context, CallableUnitCallback callback) {
    BStruct handleStruct = ((BStruct) context.getRefArgument(1));
    ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE);
    if (responseHandle == null) {
        throw new BallerinaException("invalid http handle");
    }
    BStruct bConnector = (BStruct) context.getRefArgument(0);
    HttpClientConnector clientConnector = (HttpClientConnector) bConnector.getNativeData(HttpConstants.HTTP_CLIENT);
    clientConnector.hasPushPromise(responseHandle).setPromiseAvailabilityListener(new PromiseAvailabilityCheckListener(context, callback));
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) ResponseHandle(org.wso2.transport.http.netty.message.ResponseHandle) HttpClientConnector(org.wso2.transport.http.netty.contract.HttpClientConnector) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Example 3 with ResponseHandle

use of org.wso2.transport.http.netty.message.ResponseHandle in project ballerina by ballerina-lang.

the class GetNextPromise method execute.

@Override
public void execute(Context context, CallableUnitCallback callback) {
    DataContext dataContext = new DataContext(context, callback);
    BStruct handleStruct = ((BStruct) context.getRefArgument(1));
    ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE);
    if (responseHandle == null) {
        throw new BallerinaException("invalid http handle");
    }
    BStruct bConnector = (BStruct) context.getRefArgument(0);
    HttpClientConnector clientConnector = (HttpClientConnector) bConnector.getNativeData(HttpConstants.HTTP_CLIENT);
    clientConnector.getNextPushPromise(responseHandle).setPushPromiseListener(new PromiseListener(dataContext));
}
Also used : DataContext(org.ballerinalang.net.http.DataContext) BStruct(org.ballerinalang.model.values.BStruct) ResponseHandle(org.wso2.transport.http.netty.message.ResponseHandle) HttpClientConnector(org.wso2.transport.http.netty.contract.HttpClientConnector) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Aggregations

BStruct (org.ballerinalang.model.values.BStruct)3 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)3 HttpClientConnector (org.wso2.transport.http.netty.contract.HttpClientConnector)3 ResponseHandle (org.wso2.transport.http.netty.message.ResponseHandle)3 DataContext (org.ballerinalang.net.http.DataContext)2