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();
}
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();
}
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();
}
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);
}
Aggregations