docs: private void handleHttpQuery(final TSDB tsdb, final Channel chan, final HttpRequest req) {
      AbstractHttpQuery abstractQuery = null;
      try {
        abstractQuery = createQueryInstance(tsdb, req, chan);
        if (!tsdb.getConfig().enable_chunked_requests() && req.isChunked()) {
          logError(abstractQuery, "Received an unsupported chunked request: "
              + abstractQuery.request());
          abstractQuery.badRequest(new BadRequestException("Chunked request not supported."));
          return;
        }
        // NOTE: Some methods in HttpQuery have side-effects (getQueryBaseRoute and 
        // setSerializer for instance) so invocation order is important here.
        final String route = abstractQuery.getQueryBaseRoute();
        if (abstractQuery.getClass().isAssignableFrom(HttpRpcPluginQuery.class)) {
          if (applyCorsConfig(req, abstractQuery)) {
            return;
          }
          final HttpRpcPluginQuery pluginQuery = (HttpRpcPluginQuery) abstractQuery;
          final HttpRpcPlugin rpc = rpc_manager.lookupHttpRpcPlugin(route);
        if (rpc != null) {
            rpc.execute(tsdb, pluginQuery);
        } else {
            pluginQuery.notFound();
          }
        } else if (abstractQuery.getClass().isAssignableFrom(HttpQuery.class)) {
          final HttpQuery builtinQuery = (HttpQuery) abstractQuery;
          builtinQuery.setSerializer();
          if (applyCorsConfig(req, abstractQuery)) {
            return;
          }
          final HttpRpc rpc = rpc_manager.lookupHttpRpc(route);
          if (rpc != null) {
            rpc.execute(tsdb, builtinQuery);
          } else {
            builtinQuery.notFound();
          }
        } else {
          throw new IllegalStateException("Unknown instance of AbstractHttpQuery: " 
              + abstractQuery.getClass().getName());
        }
      } catch (BadRequestException ex) {
        if (abstractQuery == null) {
          LOG.warn("{} Unable to create query for {}. Reason: {}", chan, req, ex);
          sendStatusAndClose(chan, HttpResponseStatus.BAD_REQUEST);
        } else {
          abstractQuery.badRequest(ex);
        }
      } catch (Exception ex) {
        exceptions_caught.incrementAndGet();
        if (abstractQuery == null) {
          LOG.warn("{} Unexpected error handling HTTP request {}. Reason: {} ", chan, req, ex);
          sendStatusAndClose(chan, HttpResponseStatus.INTERNAL_SERVER_ERROR);
        } else {
          abstractQuery.internalError(ex);
        }
      }
    }