Search in sources :

Example 1 with ITempFileManager

use of org.nanohttpd.protocols.http.tempfiles.ITempFileManager in project nanohttpd by NanoHttpd.

the class ClientHandler method run.

@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();
        }
    } catch (Exception e) {
        // stacktrace
        if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage())) && !(e instanceof SocketTimeoutException)) {
            NanoHTTPD.LOG.log(Level.SEVERE, "Communication with the client broken, or an bug in the handler code", e);
        }
    } finally {
        NanoHTTPD.safeClose(outputStream);
        NanoHTTPD.safeClose(this.inputStream);
        NanoHTTPD.safeClose(this.acceptSocket);
        httpd.asyncRunner.closed(this);
    }
}
Also used : SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) OutputStream(java.io.OutputStream) ITempFileManager(org.nanohttpd.protocols.http.tempfiles.ITempFileManager) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException)

Aggregations

OutputStream (java.io.OutputStream)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ITempFileManager (org.nanohttpd.protocols.http.tempfiles.ITempFileManager)1