@Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { org.apache.logging.log4j.ThreadContext.clearAll(); if(!checkAndAuthenticateRequest(request, channel, client)) { original.handleRequest(request, channel, client); } } };
/** * @return true iff the circuit breaker limit must be enforced for processing this request. */ public boolean canTripCircuitBreaker(final Optional<RestHandler> handler) { return handler.map(h -> h.canTripCircuitBreaker()).orElse(true); }
@Override public boolean supportsContentStream() { return handler.supportsContentStream(); }
sendContentTypeErrorMessage(request, channel); requestHandled = true; } else if (contentLength > 0 && mHandler.map(h -> h.supportsContentStream()).orElse(false) && request.getXContentType() != XContentType.JSON && request.getXContentType() != XContentType.SMILE) { channel.sendResponse(BytesRestResponse.createSimpleErrorResponse(channel, wrappedHandler.handleRequest(request, responseChannel, client); requestHandled = true; } catch (Exception e) {
if (restHandler != null && restHandler.supportsPlainText()) { if (isContentTypeRequired) { } else if (restHandler != null && restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) { final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT);
sendContentTypeErrorMessage(request, channel); requestHandled = true; } else if (contentLength > 0 && mHandler.map(h -> h.supportsContentStream()).orElse(false) && request.getXContentType() != XContentType.JSON && request.getXContentType() != XContentType.SMILE) { channel.sendResponse(BytesRestResponse.createSimpleErrorResponse(channel, wrappedHandler.handleRequest(request, responseChannel, client); requestHandled = true; } catch (Exception e) {
/** * {@inheritDoc} * <p> * Usage is logged via the {@link DeprecationLogger} so that the actual response can be notified of deprecation as well. */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { deprecationLogger.deprecated(deprecationMessage); handler.handleRequest(request, channel, client); }
sendContentTypeErrorMessage(request, channel); requestHandled = true; } else if (contentLength > 0 && mHandler.map(h -> h.supportsContentStream()).orElse(false) && request.getXContentType() != XContentType.JSON && request.getXContentType() != XContentType.SMILE) { channel.sendResponse(BytesRestResponse.createSimpleErrorResponse(channel, wrappedHandler.handleRequest(request, responseChannel, client); requestHandled = true; } catch (Exception e) {
/** * @return true iff the circuit breaker limit must be enforced for processing this request. */ public boolean canTripCircuitBreaker(final Optional<RestHandler> handler) { return handler.map(h -> h.canTripCircuitBreaker()).orElse(true); }
/** * If a request contains content, this method will return {@code true} if the {@code Content-Type} header is present, matches an * {@link XContentType} or the handler supports a content stream and the content type header is for newline delimited JSON, */ private static boolean hasContentType(final RestRequest restRequest, final RestHandler restHandler) { if (restRequest.getXContentType() == null) { if (restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) { final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT); // we also support newline delimited JSON: http://specs.okfnlabs.org/ndjson/ if (lowercaseMediaType.equals("application/x-ndjson")) { restRequest.setXContentType(XContentType.JSON); return true; } } return false; } return true; }
/** * {@inheritDoc} * <p> * Usage is logged via the {@link DeprecationLogger} so that the actual response can be notified of deprecation as well. */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { deprecationLogger.deprecated(deprecationMessage); handler.handleRequest(request, channel, client); }
/** * @return true iff the circuit breaker limit must be enforced for processing this request. */ public boolean canTripCircuitBreaker(final Optional<RestHandler> handler) { return handler.map(h -> h.canTripCircuitBreaker()).orElse(true); }
/** * If a request contains content, this method will return {@code true} if the {@code Content-Type} header is present, matches an * {@link XContentType} or the handler supports a content stream and the content type header is for newline delimited JSON, */ private static boolean hasContentType(final RestRequest restRequest, final RestHandler restHandler) { if (restRequest.getXContentType() == null) { if (restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) { final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT); // we also support newline delimited JSON: http://specs.okfnlabs.org/ndjson/ if (lowercaseMediaType.equals("application/x-ndjson")) { restRequest.setXContentType(XContentType.JSON); return true; } } return false; } return true; }
/** * {@inheritDoc} * <p> * Usage is logged via the {@link DeprecationLogger} so that the actual response can be notified of deprecation as well. */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { deprecationLogger.deprecated(deprecationMessage); handler.handleRequest(request, channel, client); }
/** * @param request The current request. Must not be null. * @return true iff the circuit breaker limit must be enforced for processing this request. */ public boolean canTripCircuitBreaker(RestRequest request) { RestHandler handler = getHandler(request); return (handler != null) ? handler.canTripCircuitBreaker() : true; }
/** * If a request contains content, this method will return {@code true} if the {@code Content-Type} header is present, matches an * {@link XContentType} or the handler supports a content stream and the content type header is for newline delimited JSON, */ private static boolean hasContentType(final RestRequest restRequest, final RestHandler restHandler) { if (restRequest.getXContentType() == null) { if (restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) { final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT); // we also support newline delimited JSON: http://specs.okfnlabs.org/ndjson/ if (lowercaseMediaType.equals("application/x-ndjson")) { restRequest.setXContentType(XContentType.JSON); return true; } } return false; } return true; }
@Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { org.apache.logging.log4j.ThreadContext.clearAll(); if(!checkAndAuthenticateRequest(request, channel, client)) { original.handleRequest(request, channel, client); } } };
/** * @param request The current request. Must not be null. * @return true iff the circuit breaker limit must be enforced for processing this request. */ public boolean canTripCircuitBreaker(RestRequest request) { RestHandler handler = getHandler(request); return (handler != null) ? handler.canTripCircuitBreaker() : true; }
} else if (contentLength > 0 && handler != null && handler.supportsContentStream() && request.getXContentType() != XContentType.JSON && request.getXContentType() != XContentType.SMILE) { responseChannel.sendResponse(BytesRestResponse.createSimpleErrorResponse(responseChannel,
/** * {@inheritDoc} * <p> * Usage is logged via the {@link DeprecationLogger} so that the actual response can be notified of deprecation as well. */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { deprecationLogger.deprecated(deprecationMessage); handler.handleRequest(request, channel, client); }