DCS World Typescript
    Preparing search index...
    • Assembles an HTTP response string based on the provided HttpResponse object.

      This function constructs a valid HTTP response string using the status code, headers, and body (if provided) from the HttpResponse object. It includes a default server header indicating the server is "Lua HTTP/1.1". If the status code is not recognized, it defaults to "Unknown Status".

      Parameters

      • response: HttpResponse

        The HttpResponse object containing the necessary information to construct the response string. It must include a status and headers, with an optional body.

      • options: { closeConnection?: boolean } = {}

        closeConnection: true drops any Connection header the response sets (in any letter case) and writes Connection: close after the other headers, for a server that closes every connection after one response.

      Returns string

      The complete HTTP response string, ready to be sent over the network. This string includes the start line (status line), headers, and the response body if provided. Each section is separated by CRLF (Carriage Return and Line Feed) characters.

      const response: HttpResponse = {
      status: 200,
      body: 'Hello, world!',
      headers: {
      'Content-Type': 'text/plain'
      }
      };
      const responseString = assembleResponseString(response);