class SmHttpContextHandler extends HttpServerHandler {
    static final Logger log = LoggerFactory.getLogger(SmHttpContextHandler.class);
    static final AttachKey<SmHttpContext> httpHolderKey = AttachKey.valueOf("httpHolder");

    protected Executor executor;
    private final Handler handler;

    public SmHttpContextHandler(Handler handler) {
        this.handler = handler;
    }

    public void setExecutor(Executor executor) {
        this.executor = executor;
    }

    @Override
    public void onClose(Request request) {<FILL_FUNCTION_BODY>}

    @Override
    public void handle(HttpRequest request, HttpResponse response, CompletableFuture<Object> future) throws IOException {
        SmHttpContext ctx = new SmHttpContext(request, response, future);
        if (request.getAttachment() == null) {
            request.setAttachment(new Attachment());
        }
        request.getAttachment().put(httpHolderKey, ctx);

        try {
            if (executor == null) {
                handle0(ctx, future);
            } else {
                try {
                    executor.execute(() -> {
                        handle0(ctx, future);
                    });
                } catch (RejectedExecutionException e) {
                    handle0(ctx, future);
                }
            }
        } finally {
            if (ctx.innerIsAsync() == false) {
                request.getAttachment().remove(httpHolderKey);
            }
        }
    }

    protected void handle0(SmHttpContext ctx, CompletableFuture<Object> future) {
        try {
            handleDo(ctx);
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            if (ctx.innerIsAsync() == false) {
                future.complete(ctx);
            }
        }
    }

    protected void handleDo(SmHttpContext ctx) {
        try {
            if ("PRI".equals(ctx.method())) {
                ctx.innerGetResponse().setHttpStatus(HttpStatus.NOT_IMPLEMENTED);
                return;
            }

            ctx.contentType("text/plain;charset=UTF-8");
            if (ServerProps.output_meta) {
                ctx.headerSet("Solon-Boot", XPluginImp.solon_boot_ver());
            }

            //编码窗体预处理
            FormUrlencodedUtils.pretreatment(ctx);
            handler.handle(ctx);

            if (ctx.innerIsAsync() == false) {
                ctx.innerCommit();
            }

        } catch (Throwable e) {
            log.warn(e.getMessage(), e);

            ctx.innerGetResponse().setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}

        if (request.getAttachment() == null) {
            return;
        }

        SmHttpContext ctx = request.getAttachment().get(httpHolderKey);
        if (ctx != null && ctx.innerIsAsync()) {
            try {
                for (ContextAsyncListener listener : ctx.innerAsyncListeners()) {
                    try {
                        listener.onComplete(ctx);
                    } catch (Throwable e) {
                        log.warn(e.getMessage(), e);
                    }
                }
            } finally {
                request.getAttachment().remove(httpHolderKey);
            }
        }
    
<methods>public void <init>() ,public boolean onBodyStream(java.nio.ByteBuffer, org.smartboot.http.server.impl.Request) <variables>