Search in sources :

Example 1 with VertxClientResponseToHttpServletResponse

use of org.apache.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse in project java-chassis by ServiceComb.

the class RestClientInvocation method processResponseBody.

/**
 * after this method, connection will be recycled to connection pool
 * @param responseBuf response body buffer, when download, responseBuf is null, because download data by ReadStreamPart
 */
protected void processResponseBody(Buffer responseBuf) {
    invocation.getInvocationStageTrace().finishReceiveResponse();
    invocation.getResponseExecutor().execute(() -> {
        try {
            invocation.getInvocationStageTrace().startClientFiltersResponse();
            HttpServletResponseEx responseEx = new VertxClientResponseToHttpServletResponse(clientResponse, responseBuf);
            for (HttpClientFilter filter : httpClientFilters) {
                if (filter.enabled()) {
                    Response response = filter.afterReceiveResponse(invocation, responseEx);
                    if (response != null) {
                        complete(response);
                        return;
                    }
                }
            }
        } catch (Throwable e) {
            fail(e);
        }
    });
}
Also used : AsyncResponse(org.apache.servicecomb.swagger.invocation.AsyncResponse) HttpClientResponse(io.vertx.core.http.HttpClientResponse) Response(org.apache.servicecomb.swagger.invocation.Response) VertxClientResponseToHttpServletResponse(org.apache.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse) HttpClientFilter(org.apache.servicecomb.common.rest.filter.HttpClientFilter) HttpServletResponseEx(org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx) VertxClientResponseToHttpServletResponse(org.apache.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse)

Aggregations

HttpClientResponse (io.vertx.core.http.HttpClientResponse)1 HttpClientFilter (org.apache.servicecomb.common.rest.filter.HttpClientFilter)1 HttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx)1 VertxClientResponseToHttpServletResponse (org.apache.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse)1 AsyncResponse (org.apache.servicecomb.swagger.invocation.AsyncResponse)1 Response (org.apache.servicecomb.swagger.invocation.Response)1