Search in sources :

Example 36 with HTTPCarbonMessage

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

the class Options method createOutboundRequestMsg.

protected HTTPCarbonMessage createOutboundRequestMsg(Context context) {
    HTTPCarbonMessage outboundRequestMsg = super.createOutboundRequestMsg(context);
    outboundRequestMsg.setProperty(HttpConstants.HTTP_METHOD, HttpConstants.HTTP_METHOD_OPTIONS);
    Tracer tracer = TraceUtil.getParentTracer(context.getParentWorkerExecutionContext());
    HttpUtil.injectHeaders(outboundRequestMsg, tracer.getProperties());
    tracer.addTags(HttpUtil.extractTraceTags(outboundRequestMsg));
    return outboundRequestMsg;
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Tracer(org.ballerinalang.util.tracer.Tracer)

Example 37 with HTTPCarbonMessage

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

the class Patch method createOutboundRequestMsg.

protected HTTPCarbonMessage createOutboundRequestMsg(Context context) {
    HTTPCarbonMessage outboundRequestMsg = super.createOutboundRequestMsg(context);
    outboundRequestMsg.setProperty(HttpConstants.HTTP_METHOD, HttpConstants.HTTP_METHOD_PATCH);
    Tracer tracer = TraceUtil.getParentTracer(context.getParentWorkerExecutionContext());
    HttpUtil.injectHeaders(outboundRequestMsg, tracer.getProperties());
    tracer.addTags(HttpUtil.extractTraceTags(outboundRequestMsg));
    return outboundRequestMsg;
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Tracer(org.ballerinalang.util.tracer.Tracer)

Example 38 with HTTPCarbonMessage

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

the class Put method createOutboundRequestMsg.

protected HTTPCarbonMessage createOutboundRequestMsg(Context context) {
    HTTPCarbonMessage outboundRequestMsg = super.createOutboundRequestMsg(context);
    outboundRequestMsg.setProperty(HttpConstants.HTTP_METHOD, HttpConstants.HTTP_METHOD_PUT);
    Tracer tracer = TraceUtil.getParentTracer(context.getParentWorkerExecutionContext());
    HttpUtil.injectHeaders(outboundRequestMsg, tracer.getProperties());
    tracer.addTags(HttpUtil.extractTraceTags(outboundRequestMsg));
    return outboundRequestMsg;
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Tracer(org.ballerinalang.util.tracer.Tracer)

Example 39 with HTTPCarbonMessage

use of org.wso2.transport.http.netty.message.HTTPCarbonMessage 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);
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise) BValue(org.ballerinalang.model.values.BValue) HttpResponseFuture(org.wso2.transport.http.netty.contract.HttpResponseFuture)

Example 40 with HTTPCarbonMessage

use of org.wso2.transport.http.netty.message.HTTPCarbonMessage 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);
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Http2PushPromise(org.wso2.transport.http.netty.message.Http2PushPromise) BValue(org.ballerinalang.model.values.BValue) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Aggregations

HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)308 Test (org.testng.annotations.Test)247 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)233 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)179 BJSON (org.ballerinalang.model.values.BJSON)108 BString (org.ballerinalang.model.values.BString)45 BStruct (org.ballerinalang.model.values.BStruct)43 Request (org.wso2.msf4j.Request)34 ArrayList (java.util.ArrayList)25 BValue (org.ballerinalang.model.values.BValue)19 Header (org.wso2.carbon.messaging.Header)14 Tracer (org.ballerinalang.util.tracer.Tracer)11 HttpCarbonMessage (org.wso2.transport.http.netty.message.HttpCarbonMessage)10 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)9 IOException (java.io.IOException)8 ResponseCacheControlStruct (org.ballerinalang.net.http.caching.ResponseCacheControlStruct)7 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)5 Semaphore (java.util.concurrent.Semaphore)5 APIMgtSecurityException (org.wso2.carbon.apimgt.rest.api.common.exception.APIMgtSecurityException)5 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)4