public void filter()

in zuul-core/src/main/java/com/netflix/zuul/netty/filter/ZuulEndPointRunner.java [143:180]


    public void filter(HttpRequestMessage zuulReq, HttpContent chunk) {
        if (zuulReq.getContext().isCancelled()) {
            chunk.release();
            return;
        }

        String endpointName = "-";
        try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".filterChunk")) {
            addPerfMarkTags(zuulReq);
            ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint =
                    Preconditions.checkNotNull(getEndpoint(zuulReq), "endpoint");
            endpointName = endpoint.filterName();

            ByteBufUtil.touch(chunk, "Endpoint processing chunk, ZuulMessage: ", zuulReq);
            HttpContent newChunk = endpoint.processContentChunk(zuulReq, chunk);
            if (newChunk != null) {
                ByteBufUtil.touch(newChunk, "Endpoint buffering newChunk, ZuulMessage: ", zuulReq);
                // Endpoints do not directly forward content chunks to next stage in the filter chain.
                zuulReq.bufferBodyContents(newChunk);

                // deallocate original chunk if necessary
                if (newChunk != chunk) {
                    chunk.release();
                }

                if (isFilterAwaitingBody(zuulReq.getContext())
                        && zuulReq.hasCompleteBody()
                        && !(endpoint instanceof ProxyEndpoint)) {
                    // whole body has arrived, resume filter chain
                    ByteBufUtil.touch(newChunk, "Endpoint body complete, resume chain, ZuulMessage: ", zuulReq);
                    invokeNextStage(filter(endpoint, zuulReq));
                }
            }
        } catch (Exception ex) {
            ReferenceCountUtil.safeRelease(chunk);
            handleException(zuulReq, endpointName, ex);
        }
    }