Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle function called twice #2242

Open
weizai opened this issue May 13, 2024 · 2 comments
Open

handle function called twice #2242

weizai opened this issue May 13, 2024 · 2 comments
Labels

Comments

@weizai
Copy link

weizai commented May 13, 2024

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?

@tipsy tipsy added the QUESTION label May 13, 2024
@tipsy
Copy link
Member

tipsy commented May 13, 2024

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

@weizai
Copy link
Author

weizai commented May 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants