javalin / javalin

A simple and modern Java and Kotlin web framework

Home Page:https://javalin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

handle function called twice

weizai opened this issue · comments

code is:

app.get("/testAudio", new Handler() {
            @Override
            public void handle(@NotNull Context ctx) throws Exception {
                String text = ctx.queryParam("text");
                String voiceName = ctx.queryParam("voiceName");
                byte[] result = TTS.convertStream(text, voiceName);
                ctx.header("Content-Type", ContentType.AUDIO_MPEG.getMimeType());
                ctx.header("Content-Length", String.valueOf(result.length));
                ctx.result(result);
            }
        });

handle function called twice when Context‘s header set ContentType.AUDIO_MPEG, it is a bug?

Hi @weizai - most likely your client/browser is calling the Handler twice, there should be nothing on Javalin that could cause this.

yes, i found it, the handle function called twice when request from browser, and it is just fine from postman。however, when i set ctx.header("Content-Type", MINE_TYPE);
MINE_TYPE can be any, except 'audio/mpeg', it is just fine from browser. what’s going on