DCS World Typescript
    Preparing search index...

    Optional configuration for HttpServer. Every field has a default (see DEFAULT_SERVER_OPTIONS).

    The defaults are conservative initial settings chosen for small JSON APIs embedded in DCS World. They are not measured recommendations; tune them against your own workload.

    Declared request bodies share one budget, maxBufferedBodyBytes: a body is reserved when its head arrives, and one that does not fit gets 503 before anything is read or dispatched. Serialized responses are bounded per connection by maxResponseBytes and in time by responseTimeout; they are deliberately not part of the body budget, so clients that stop reading large responses cannot make the server refuse small requests from everyone else. Each connection also holds at most maxRequestHeaderBytes + ioChunkBytes bytes of head. The server's own buffers are therefore bounded by

    maxBufferedBodyBytes + maxConnections * (maxRequestHeaderBytes + ioChunkBytes + maxResponseBytes)
    

    which is 32 MiB + 64 * (16 KiB + 4 MiB), about 289 MiB, with the defaults. That worst case needs 64 clients each leaving a 4 MiB response unread; lower maxResponseBytes or maxConnections if your responses are small or your clients few. Objects the request handler builds (for example the response body string before serialization) are outside this bound.

    interface HttpServerOptions {
        clock?: Clock;
        idleTimeout?: number;
        ioChunkBytes?: number;
        maxAcceptsPerPump?: number;
        maxBufferedBodyBytes?: number;
        maxConnections?: number;
        maxDispatchesPerPump?: number;
        maxIoBytesPerPump?: number;
        maxIoBytesPerVisit?: number;
        maxPumpSeconds?: number;
        maxRequestBodyBytes?: number;
        maxRequestHeaderBytes?: number;
        maxRequestHeaderCount?: number;
        maxResponseBytes?: number;
        maxVisitsPerPump?: number;
        requestTimeout?: number;
        responseTimeout?: number;
    }
    Index
    clock?: Clock

    The clock used for deadlines and the pump time budget. Defaults to LuaSocket's socket.gettime, which is wall-clock (Unix) time and follows system clock adjustments. The server never lets its view of time go backwards: a backwards adjustment pauses deadlines until the clock catches up, and a forward adjustment expires them early. Do not pass simulation time (for example DCS's timer.getTime), which stops while the simulation is paused and would keep network deadlines from expiring.

    idleTimeout?: number

    Seconds a connection may go without receiving a request byte before it gets 408, in addition to requestTimeout. 0 disables it. Default 0.

    ioChunkBytes?: number

    The most bytes read or written by a single socket call. Default 8192.

    maxAcceptsPerPump?: number

    The most connections accepted in one pump. Default 4.

    maxBufferedBodyBytes?: number

    The most bytes of declared request bodies held across all connections: a body that does not fit gets 503 (see the memory bound above). Default 33554432 (32 MiB).

    maxConnections?: number

    The most connections held open at once. When it is reached the server stops accepting; further clients wait in the operating system's listen backlog until a slot frees up. An open connection that has sent nothing costs little, so this is set well above the expected number of clients: a low value lets a few idle or slow clients occupy every slot until their deadlines expire. Default 64.

    maxDispatchesPerPump?: number

    The most request handlers run in one pump. Default 4.

    maxIoBytesPerPump?: number

    The most bytes read plus written across all connections in one HttpServer.pump. Default 262144.

    maxIoBytesPerVisit?: number

    The most bytes read plus written for one connection in one visit, so busy connections share a pump. Default 32768.

    maxPumpSeconds?: number

    A cooperative time budget for one pump, in seconds of clock. It is checked between operations: a handler that is already running is never interrupted, and no new handler starts once it is spent, not even the pump's first (a request refused for time goes first in the next pump). The first accept and the first connection visit of a pump always happen, so sockets keep being serviced. Default 0.005. The default clock is the wall clock, whose resolution is coarse on some platforms (around 15 ms on Windows), so treat this as a soft limit.

    maxRequestBodyBytes?: number

    The largest accepted Content-Length. Larger declarations get 413 before any body is read. Default 1048576 (1 MiB).

    maxRequestHeaderBytes?: number

    The most bytes in the request line plus headers, terminator included. Larger heads get 431. Default 8192.

    maxRequestHeaderCount?: number

    The most header lines in a request. More get 431. Default 64.

    maxResponseBytes?: number

    The largest serialized response retained for sending. A larger response is replaced by 500. Default 4194304 (4 MiB).

    maxVisitsPerPump?: number

    The most connection visits in one pump. Each connection is visited at most once per pump. Default 32.

    requestTimeout?: number

    Seconds from accepting a connection until its request must be completely received. An absolute deadline: receiving more bytes does not extend it. On expiry the client gets 408. Default 10.

    responseTimeout?: number

    Seconds from starting a response until it must be completely handed to the socket. On expiry the connection is closed without the rest of the response. Default 30.