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

found a little issue when using nanohttpd with javafx webview. #566

Closed
KnIfER opened this issue Oct 27, 2019 · 0 comments
Closed

found a little issue when using nanohttpd with javafx webview. #566

KnIfER opened this issue Oct 27, 2019 · 0 comments

Comments

@KnIfER
Copy link

KnIfER commented Oct 27, 2019

This issue only occurs if you are using this library to play a wav audio in a webview of jdk1.8 javafx via js audio API. like:

var audio = new Audio();
audio.src = "http://127.0.0.1:8080/ld45happy.mp3";
audio.play();

//and in the java server side  : 
return newFixedLengthResponse(Status.OK,"audio/x-wav", new ByteArrayInputStream(WavData), WavData.length);

In the webview of jdk1.8 javafx , no audio will be played :

(webview console log) Unhandled Promise Rejection: [object DOMError]

To solve this, I just need to add a line in Response.java,line#313:

void sendBodyWithCorrectEncoding(OutputStream outputStream, long pending) {//method former name : sendAsFixedLength
    if(this.requestMethod != Method.HEAD && this.data != null) // +++
    ……

The if-check had been there before a45eb0e . And after the introduce of gzip support , it was gone.

Although this little issue does not seem to occur in other browsers , I think it's better to and the if-check back.

@KnIfER KnIfER closed this as completed Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant