protected ZuulException proxyError(HttpRequestMessage zuulReq, Throwable t, String errorCauseMsg) { // Flag this as a proxy failure in the RequestContext. Error filter will then use this flag. zuulReq.getContext().setShouldSendErrorResponse(true); LOG.error(String.format("Error making http request to Origin. restClientName=%s, url=%s", this.name, zuulReq.getPathAndQuery()), t); if (errorCauseMsg == null) { if (t.getCause() != null) { errorCauseMsg = t.getCause().getMessage(); } } if (errorCauseMsg == null) errorCauseMsg = "unknown"; return new ZuulException("Proxying error", t, errorCauseMsg); }
public static HttpClientRequest<ByteBuf> createHttpClientRequest(HttpRequestMessage zuulReq) { HttpClientRequest<ByteBuf> clientReq = HttpClientRequest.create(HttpMethod.valueOf(zuulReq.getMethod().toUpperCase()), zuulReq.getPathAndQuery()); for (Map.Entry<String, String> entry : zuulReq.getHeaders().entries()) { // TODO - should we be filtering headers here like we do when using Ribbon? clientReq = clientReq.withHeader(entry.getKey(), entry.getValue()); } if (zuulReq.getBodyStream() != null) { clientReq = clientReq.withContentSource(zuulReq.getBodyStream()); } return clientReq; }
this.vip, requestMsg.getPathAndQuery(), serverInfo.getHost()), t);
@Override public void handle(HttpResponseMessage response) { HttpRequestMessage request = response.getRequest(); SessionContext context = response.getContext(); long duration = context.getTimings().getRequest().getDuration(); int responseBodySize = response.getBody() == null ? 0 : response.getBody().length; // Write to access log. accessLogPublisher.publish(new SimpleAccessRecord(LocalDateTime.now(), response.getStatus(), request.getMethod(), request.getPathAndQuery(), duration, responseBodySize, request.getHeaders(), response.getHeaders() )); // Publish request-level metrics. if (requestMetricsPublisher != null) { requestMetricsPublisher.collectAndPublish(context); } } }