private String getPath(RestRequest request) { // we use rawPath since we don't want to decode it while processing the path resolution // so we can handle things like: // my_index/my_type/http%3A%2F%2Fwww.google.com return request.rawPath(); }
/** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); }
@Override public void dispatchRequest(RestRequest request, RestChannel channel, ThreadContext threadContext) { if (request.rawPath().equals("/favicon.ico")) { handleFavicon(request, channel); return; } try { tryAllHandlers(request, channel, threadContext); } catch (Exception e) { try { channel.sendResponse(new BytesRestResponse(channel, e)); } catch (Exception inner) { inner.addSuppressed(e); logger.error(() -> new ParameterizedMessage("failed to send failure response for uri [{}]", request.uri()), inner); } } }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
private String getPath(RestRequest request) { // we use rawPath since we don't want to decode it while processing the path resolution // so we can handle things like: // my_index/my_type/http%3A%2F%2Fwww.google.com return request.rawPath(); }
private String getPath(RestRequest request) { // we use rawPath since we don't want to decode it while processing the path resolution // so we can handle things like: // my_index/my_type/http%3A%2F%2Fwww.google.com return request.rawPath(); }
private String getPath(RestRequest request) { // we use rawPath since we don't want to decode it while processing the path resolution // so we can handle things like: // my_index/my_type/http%3A%2F%2Fwww.google.com return request.rawPath(); }
private String getPath(RestRequest request) { // we use rawPath since we don't want to decode it while processing the path resolution // so we can handle things like: // my_index/my_type/http%3A%2F%2Fwww.google.com return request.rawPath(); }
/** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); }
/** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); }
/** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); }
/** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); }
@Override public void dispatchRequest(RestRequest request, RestChannel channel, ThreadContext threadContext) { if (request.rawPath().equals("/favicon.ico")) { handleFavicon(request, channel); return; } try { tryAllHandlers(request, channel, threadContext); } catch (Exception e) { try { channel.sendResponse(new BytesRestResponse(channel, e)); } catch (Exception inner) { inner.addSuppressed(e); logger.error(() -> new ParameterizedMessage("failed to send failure response for uri [{}]", request.uri()), inner); } } }
@Override public void dispatchRequest(RestRequest request, RestChannel channel, ThreadContext threadContext) { if (request.rawPath().equals("/favicon.ico")) { handleFavicon(request, channel); return; } try { tryAllHandlers(request, channel, threadContext); } catch (Exception e) { try { channel.sendResponse(new BytesRestResponse(channel, e)); } catch (Exception inner) { inner.addSuppressed(e); logger.error(() -> new ParameterizedMessage("failed to send failure response for uri [{}]", request.uri()), inner); } } }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
public EditableRestRequest(final RestRequest innerRestquest) { this.innerRestquest = innerRestquest; content = innerRestquest.content(); params = innerRestquest.params(); method = innerRestquest.method(); uri = innerRestquest.uri(); rawPath = innerRestquest.rawPath(); hasContent = innerRestquest.hasContent(); contentUnsafe = innerRestquest.contentUnsafe(); }
public void dispatchRequest(final RestRequest request, final RestChannel channel) { try { if (request instanceof NettyHttpRequest) { NettyHttpRequest nettyHttpRequest = (NettyHttpRequest)request; if ("PATCH".equalsIgnoreCase(nettyHttpRequest.getMethod())) { RestHandler handler = patchHandlers.retrieve(request.rawPath()); if (handler != null) { handler.handleRequest(request, channel); } } } } catch (Throwable e) { try { channel.sendResponse(new BytesRestResponse(channel, e)); } catch (Throwable e1) { logger.error("failed to send failure response for uri [" + request.uri() + "]", e1); } } } }
public void internalDispatchRequest(final RestRequest request, final RestChannel channel) { String rawPath = request.rawPath(); if (rawPath.startsWith("/_plugin/")) { RestFilterChain filterChain = restController.filterChain(pluginSiteFilter); filterChain.continueProcessing(request, channel); return; } else if (rawPath.equals("/favicon.ico")) { handleFavicon(request, channel); return; } RestChannel responseChannel = channel; try { int contentLength = request.content().length(); if (restController.canTripCircuitBreaker(request)) { inFlightRequestsBreaker(circuitBreakerService).addEstimateBytesAndMaybeBreak(contentLength, "<http_request>"); } else { inFlightRequestsBreaker(circuitBreakerService).addWithoutBreaking(contentLength); } // iff we could reserve bytes for the request we need to send the response also over this channel responseChannel = new ResourceHandlingHttpChannel(channel, circuitBreakerService); restController.dispatchRequest(request, responseChannel); } catch (Throwable t) { restController.sendErrorResponse(request, responseChannel, t); } }