use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.
the class ZuulFilterChainHandler method fireEndpointFinish.
protected void fireEndpointFinish(final boolean error) {
final ZuulFilter endpoint = ZuulEndPointRunner.getEndpoint(zuulRequest);
if (endpoint instanceof ProxyEndpoint) {
final ProxyEndpoint edgeProxyEndpoint = (ProxyEndpoint) endpoint;
edgeProxyEndpoint.finish(error);
}
zuulRequest = null;
}
use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.
the class ZuulEndPointRunner method filter.
@Override
public void filter(final HttpRequestMessage zuulReq) {
if (zuulReq.getContext().isCancelled()) {
PerfMark.event(getClass().getName(), "filterCancelled");
zuulReq.disposeBufferedBody();
logger.debug("Request was cancelled, UUID {}", zuulReq.getContext().getUUID());
return;
}
final String endpointName = getEndPointName(zuulReq.getContext());
try (TaskCloseable ignored = PerfMark.traceTask(this, s -> s.getClass().getSimpleName() + ".filter")) {
Preconditions.checkNotNull(zuulReq, "input message");
addPerfMarkTags(zuulReq);
final ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint = getEndpoint(endpointName, zuulReq);
logger.debug("Got endpoint {}, UUID {}", endpoint.filterName(), zuulReq.getContext().getUUID());
setEndpoint(zuulReq, endpoint);
final HttpResponseMessage zuulResp = filter(endpoint, zuulReq);
if ((zuulResp != null) && (!(endpoint instanceof ProxyEndpoint))) {
// EdgeProxyEndpoint calls invokeNextStage internally
logger.debug("Endpoint calling invokeNextStage, UUID {}", zuulReq.getContext().getUUID());
invokeNextStage(zuulResp);
}
} catch (Exception ex) {
handleException(zuulReq, endpointName, ex);
}
}
use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.
the class OriginResponseReceiver method fireWriteError.
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
String errMesg = "Error while proxying " + requestPart + " to origin ";
if (edgeProxy != null) {
final ProxyEndpoint ep = edgeProxy;
edgeProxy = null;
errMesg += ep.getOrigin().getName();
ep.errorFromOrigin(cause);
}
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
use of com.netflix.zuul.filters.endpoint.ProxyEndpoint in project zuul by Netflix.
the class ZuulEndPointRunner method filter.
@Override
public void filter(final HttpRequestMessage zuulReq, final 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();
final HttpContent newChunk = endpoint.processContentChunk(zuulReq, chunk);
if (newChunk != null) {
// 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) && zuulReq.hasCompleteBody() && !(endpoint instanceof ProxyEndpoint)) {
// whole body has arrived, resume filter chain
invokeNextStage(filter(endpoint, zuulReq));
}
}
} catch (Exception ex) {
handleException(zuulReq, endpointName, ex);
}
}
Aggregations