Interface HttpServer.BodyWriter

Enclosing class:
HttpServer

public static interface HttpServer.BodyWriter

Generates a response on the serving worker, with bounded transport buffering. Open sources inside writeTo and close them with try-with-resources. The server invokes this only for responses that carry a body, never for HEAD or a bodiless status. Capture request values in the handler; do not retain the Request or output. A disconnect, reset or socket timeout makes writes throw IOException; let it propagate so generation stops and source cleanup runs. No temporary files or producer threads are created. Closing output flushes it, but not the connection.

A writer that holds something open until it runs -- an upstream connection, a file -- should also implement java.io.Closeable. The server does not always call writeTo(OutputStream): a HEAD request, a status that carries no body, an HTTP/2 stream it cannot open, or a client gone before the headers were written all skip it. In each of those it calls close() instead, so the writer's resource is released either way.

  • Method Summary

    Modifier and Type
    Method
    Description
    void