Search in sources :

Example 16 with Http2PushPromise

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

the class RemoveAllHeaders method execute.

@Override
public void execute(Context context) {
    BStruct pushPromiseStruct = (BStruct) context.getRefArgument(0);
    Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, HttpUtil.createHttpPushPromise(pushPromiseStruct));
    http2PushPromise.removeAllHeaders();
    context.setReturnValues();
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise)

Example 17 with Http2PushPromise

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

the class RemoveHeader 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);
    http2PushPromise.removeHeader(headerName);
    context.setReturnValues();
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise)

Example 18 with Http2PushPromise

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

the class SetHeader 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);
    String headerValue = context.getStringArgument(1);
    http2PushPromise.setHeader(headerName, headerValue);
    context.setReturnValues();
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise)

Example 19 with Http2PushPromise

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

the class PushPromiseNativeFunctionTest method testGetHeader.

@Test(description = "Test getHeader function of PushPromise")
public void testGetHeader() {
    BStruct promise = BCompileUtil.createAndGetStruct(result.getProgFile(), protocolPackageHttp, promiseStruct);
    Http2PushPromise http2PushPromise = new Http2PushPromise(HttpConstants.HTTP_METHOD_GET, HttpConstants.DEFAULT_BASE_PATH);
    String headerName = "header1";
    String headerValue = "value1";
    http2PushPromise.addHeader(headerName, headerValue);
    HttpUtil.populatePushPromiseStruct(promise, http2PushPromise);
    BString key = new BString(headerName);
    BValue[] inputArg = { promise, key };
    BValue[] returnVal = BRunUtil.invoke(result, "testGetHeader", inputArg);
    Assert.assertFalse(returnVal == null || returnVal.length == 0 || returnVal[0] == null, "Invalid Return Values.");
    Assert.assertEquals(returnVal[0].stringValue(), headerValue);
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise) BString(org.ballerinalang.model.values.BString) BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Aggregations

Http2PushPromise (org.wso2.transport.http.netty.message.Http2PushPromise)18 BStruct (org.ballerinalang.model.values.BStruct)17 BString (org.ballerinalang.model.values.BString)8 BValue (org.ballerinalang.model.values.BValue)8 Test (org.testng.annotations.Test)6 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)3 HttpClientConnector (org.wso2.transport.http.netty.contract.HttpClientConnector)2 HttpResponseFuture (org.wso2.transport.http.netty.contract.HttpResponseFuture)2 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)2 BBoolean (org.ballerinalang.model.values.BBoolean)1 BStringArray (org.ballerinalang.model.values.BStringArray)1 DataContext (org.ballerinalang.net.http.DataContext)1 MessageDataSource (org.ballerinalang.runtime.message.MessageDataSource)1