NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.89k stars 1.69k forks source link

an infinite loop bug #621

Open yeshengchen opened 2 years ago

yeshengchen commented 2 years ago

if the header exceeds 8192 bytes and the connection is keepalive, the following code will go into an infinite loop.

public class ClientHandler implements Runnable {

    ......

    @Override
    public void run() {
        OutputStream outputStream = null;
        try {
            outputStream = this.acceptSocket.getOutputStream();
            ITempFileManager tempFileManager = httpd.getTempFileManagerFactory().create();
            HTTPSession session = new HTTPSession(httpd, tempFileManager, this.inputStream, outputStream, this.acceptSocket.getInetAddress());
            while (!this.acceptSocket.isClosed()) {
                session.execute();   //here
            }
        } catch (Exception e) {
            ......
        } finally {
            ......
        }
    }
    ......
}