{
  "classes": [
    {
      "constants": [],
      "types": [
        {
          "lua_type": "type HttpServerOptions = {\n    host: string?,\n    port: number?,\n    backlog: number?,\n    clientTimeout: number?,\n    keepAliveTimeout: number?,\n    maxRequestsPerConnection: number?,\n    maxHeaderBytes: number?,\n    maxBodyBytes: number?,\n    streamRequestBodies: boolean?,\n    sslCtx: _ssl.SslContext?,\n}",
          "name": "HttpServerOptions",
          "tags": [],
          "source": {
            "path": "",
            "line": 122
          },
          "fields": [
            {
              "lua_type": "host: string?",
              "name": "host",
              "desc": ""
            },
            {
              "lua_type": "port: number?",
              "name": "port",
              "desc": ""
            },
            {
              "lua_type": "backlog: number?",
              "name": "backlog",
              "desc": ""
            },
            {
              "lua_type": "clientTimeout: number?",
              "name": "clientTimeout",
              "desc": ""
            },
            {
              "lua_type": "keepAliveTimeout: number?",
              "name": "keepAliveTimeout",
              "desc": ""
            },
            {
              "lua_type": "maxRequestsPerConnection: number?",
              "name": "maxRequestsPerConnection",
              "desc": ""
            },
            {
              "lua_type": "maxHeaderBytes: number?",
              "name": "maxHeaderBytes",
              "desc": ""
            },
            {
              "lua_type": "maxBodyBytes: number?",
              "name": "maxBodyBytes",
              "desc": ""
            },
            {
              "lua_type": "streamRequestBodies: boolean?",
              "name": "streamRequestBodies",
              "desc": "When true, request bodies are exposed through `req.bodyStream`\ninstead of being buffered eagerly."
            },
            {
              "lua_type": "sslCtx: _ssl.SslContext?",
              "name": "sslCtx",
              "desc": ""
            }
          ],
          "desc": "Options for creating an [[HttpServer]].\n"
        }
      ],
      "name": "@eryx/http/HttpServer",
      "tags": [],
      "functions": [
        {
          "source": {
            "path": "",
            "line": 405
          },
          "is_method": true,
          "signature": "ServerRequestMethods:readBody() → (\n    string  -- The full request body. \n)",
          "owner": "ServerRequestMethods",
          "desc": "Reads and buffers the full request body on demand.\n\nIn default buffered mode this simply returns `req.body`. When streamed\nrequest-body mode is enabled, this drains `req.bodyStream` and caches\nthe result.\n",
          "tags": [],
          "name": "readBody",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The full request body. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 425
          },
          "is_method": true,
          "signature": "ServerRequestMethods:readForm() → (\n    QueryTable?  -- The decoded form fields, or `nil` when the request is not URL-encoded. \n)",
          "owner": "ServerRequestMethods",
          "desc": "Decodes a request body as `application/x-www-form-urlencoded`.\n\nIn streamed request-body mode this reads the full body on demand.\n",
          "tags": [],
          "name": "readForm",
          "return_str": "QueryTable?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "QueryTable?",
              "desc": "The decoded form fields, or `nil` when the request is not URL-encoded. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 447
          },
          "is_method": true,
          "signature": "ServerRequestMethods:readMultipart() → (\n    { ParsedMultipartField }?  -- Parsed multipart fields, or `nil` when the request is not multipart form-data. \n)",
          "owner": "ServerRequestMethods",
          "desc": "Decodes a request body as `multipart/form-data`.\n\nIn streamed request-body mode this reads the full body on demand.\n",
          "tags": [],
          "name": "readMultipart",
          "return_str": "{ ParsedMultipartField }?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "{ ParsedMultipartField }?",
              "desc": "Parsed multipart fields, or `nil` when the request is not multipart form-data. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 474
          },
          "is_method": true,
          "signature": "ServerRequestMethods:readJson() → (\n    any?  -- The decoded JSON value, or `nil` when the request does not declare a JSON content type. \n)",
          "owner": "ServerRequestMethods",
          "desc": "Decodes a request body as JSON.\n\nIn streamed request-body mode this reads the full body on demand.\n",
          "tags": [],
          "name": "readJson",
          "return_str": "any?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "any?",
              "desc": "The decoded JSON value, or `nil` when the request does not declare a JSON content type. "
            }
          ],
          "params": []
        }
      ],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": ""
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 32
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "_closed: boolean",
          "name": "_closed",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_sock: any",
          "name": "_sock",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_buffer: string",
          "name": "_buffer",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_trailers: { [string]: string }?",
          "name": "_trailers",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_mode: \"empty\" | \"length\" | \"chunked\"",
          "name": "_mode",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_remaining: number",
          "name": "_remaining",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_chunkRemaining: number",
          "name": "_chunkRemaining",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_totalRead: number",
          "name": "_totalRead",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_maxBodyBytes: number",
          "name": "_maxBodyBytes",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_onFinish: (((string, { [string]: string }?) → ()))?",
          "name": "_onFinish",
          "desc": ""
        }
      ],
      "desc": "",
      "name": "RequestBodyStream",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 183
          },
          "is_method": true,
          "signature": "RequestBodyStream:_finish() → ()",
          "owner": "RequestBodyStream",
          "desc": "",
          "tags": [],
          "name": "_finish",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 195
          },
          "is_method": true,
          "signature": "RequestBodyStream:_recvChunk() → string",
          "owner": "RequestBodyStream",
          "desc": "",
          "tags": [],
          "name": "_recvChunk",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 226
          },
          "is_method": true,
          "signature": "RequestBodyStream:_recvUntil(delim: string) → string",
          "owner": "RequestBodyStream",
          "desc": "",
          "tags": [],
          "name": "_recvUntil",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "delim",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 241
          },
          "is_method": true,
          "signature": "RequestBodyStream:_recvExact(n: number) → string",
          "owner": "RequestBodyStream",
          "desc": "",
          "tags": [],
          "name": "_recvExact",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "n",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 253
          },
          "is_method": true,
          "signature": "RequestBodyStream:_readChunkHeader() → ()",
          "owner": "RequestBodyStream",
          "desc": "",
          "tags": [],
          "name": "_readChunkHeader",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 292
          },
          "is_method": true,
          "signature": "RequestBodyStream:read(\n    count: number?  -- Maximum number of bytes to read. Defaults to `65536`.\n) → (\n    string?  -- The next body chunk, or `nil` when the stream ends. \n)",
          "owner": "RequestBodyStream",
          "desc": "Reads a chunk from a streamed request body.\n\nIn streamed request-body mode, handlers receive `req.bodyStream`, which\nexposes `read`, `readAll`, and `close` for incremental upload\nprocessing.\n",
          "tags": [],
          "name": "read",
          "return_str": "string?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string?",
              "desc": "The next body chunk, or `nil` when the stream ends. "
            }
          ],
          "params": [
            {
              "lua_type": "number?",
              "name": "count",
              "desc": "Maximum number of bytes to read. Defaults to `65536`."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 351
          },
          "is_method": true,
          "signature": "RequestBodyStream:readAll() → (\n    string  -- The remaining request body. \n)",
          "owner": "RequestBodyStream",
          "desc": "Reads the rest of a streamed request body into a string.\n",
          "tags": [],
          "name": "readAll",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The remaining request body. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 369
          },
          "is_method": true,
          "signature": "RequestBodyStream:close() → ()",
          "owner": "RequestBodyStream",
          "desc": "Consumes and closes a streamed request body.\n\nThis is useful when a handler wants to abandon the body early but still\nallow the connection to be reused safely.\n",
          "tags": [],
          "name": "close",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": []
        }
      ],
      "metamethods": [],
      "types": []
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 39
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "method: string",
          "name": "method",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "path: string",
          "name": "path",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "pathname: string",
          "name": "pathname",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "queryString: string",
          "name": "queryString",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "query: QueryTable",
          "name": "query",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "httpVersion: string",
          "name": "httpVersion",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "headers: { [string]: string }",
          "name": "headers",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "trailers: { [string]: string }",
          "name": "trailers",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "contentType: string?",
          "name": "contentType",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "body: string",
          "name": "body",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "form: QueryTable?",
          "name": "form",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "multipart: { ParsedMultipartField }?",
          "name": "multipart",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "bodyStream: RequestBodyStream?",
          "name": "bodyStream",
          "desc": "Available when `streamRequestBodies = true`."
        },
        {
          "tags": [],
          "lua_type": "remoteAddr: string",
          "name": "remoteAddr",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "remotePort: number",
          "name": "remotePort",
          "desc": ""
        }
      ],
      "desc": "An incoming HTTP request received by an [[HttpServer]].\n\nHeader names are lowercased for consistent lookup.\n",
      "name": "ServerRequest",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 57
          },
          "is_method": true,
          "signature": "ServerRequest:readBody() → string",
          "desc": "Reads and buffers the full body on demand.",
          "tags": [],
          "name": "readBody",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 59
          },
          "is_method": true,
          "signature": "ServerRequest:readForm() → QueryTable?",
          "desc": "Decodes URL-encoded form data on demand.",
          "tags": [],
          "name": "readForm",
          "return_str": "QueryTable?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "QueryTable?",
              "desc": ""
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 61
          },
          "is_method": true,
          "signature": "ServerRequest:readMultipart() → { ParsedMultipartField }?",
          "desc": "Decodes multipart form-data on demand.",
          "tags": [],
          "name": "readMultipart",
          "return_str": "{ ParsedMultipartField }?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "{ ParsedMultipartField }?",
              "desc": ""
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 63
          },
          "is_method": true,
          "signature": "ServerRequest:readJson() → any?",
          "desc": "Decodes JSON request bodies on demand.",
          "tags": [],
          "name": "readJson",
          "return_str": "any?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "any?",
              "desc": ""
            }
          ],
          "params": []
        }
      ],
      "metamethods": [],
      "types": []
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 117
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "_host: string",
          "name": "_host",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_port: number",
          "name": "_port",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_backlog: number",
          "name": "_backlog",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_clientTimeout: number",
          "name": "_clientTimeout",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_keepAliveTimeout: number",
          "name": "_keepAliveTimeout",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_maxRequestsPerConnection: number?",
          "name": "_maxRequestsPerConnection",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_maxHeaderBytes: number",
          "name": "_maxHeaderBytes",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_maxBodyBytes: number",
          "name": "_maxBodyBytes",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_streamRequestBodies: boolean",
          "name": "_streamRequestBodies",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_callback: ServerCallback",
          "name": "_callback",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_sock: _socket.Socket?",
          "name": "_sock",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_running: boolean",
          "name": "_running",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_sslCtx: any?",
          "name": "_sslCtx",
          "desc": "TLS fields (nil for plain HTTP)"
        }
      ],
      "desc": "A single-threaded HTTP (or HTTPS) server.\n\nCreate one with [[createServer]], then call [[HttpServer.listen]] to\nstart accepting connections. Provide an `sslCtx` in the options\nto enable HTTPS.\n\n```luau\nlocal server = http.createServer(function(req, res)\n    print(req.method, req.path)\n    res:send(200, \"OK\")\nend, { port = 8080 })\nserver:listen()\n```\n",
      "name": "HttpServer",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 157
          },
          "is_method": false,
          "signature": "HttpServer.new(\n    callback: ServerCallback,  -- The handler invoked for each incoming request.\n    options: HttpServerOptions?  -- Server configuration options.\n) → (\n    HttpServer  -- The new server (not yet listening). \n)",
          "owner": "HttpServer",
          "desc": "Creates a new [[HttpServer]] with the given request handler.\n\nCall [[HttpServer.listen]] on the returned server to start accepting\nconnections.\n\n```luau\nlocal server = http.createServer(function(req, res)\n    print(req.method, req.path)\n    res:send(200, \"Hello, world!\")\nend)\nserver:listen(function(host, port)\n    print(\"Listening on \" .. host .. \":\" .. tostring(port))\nend)\n```\n",
          "tags": [],
          "name": "new",
          "return_str": "HttpServer",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "HttpServer",
              "desc": "The new server (not yet listening). "
            }
          ],
          "params": [
            {
              "lua_type": "ServerCallback",
              "name": "callback",
              "desc": "The handler invoked for each incoming request."
            },
            {
              "lua_type": "HttpServerOptions?",
              "name": "options",
              "desc": "Server configuration options."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 490
          },
          "is_method": true,
          "signature": "HttpServer:listen(\n    callback: (((host: string, port: number) → ()))?  -- Called with `(host, port)` when the server is ready. \n) → never",
          "owner": "HttpServer",
          "desc": "Starts listening for connections and serves requests.\n\nThis call **blocks** until [[HttpServer.close]] is called or the process\nis interrupted. The optional callback is invoked once the socket is\nbound and ready to accept connections.\n",
          "tags": [],
          "name": "listen",
          "return_str": "never",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "never",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "(((host: string, port: number) → ()))?",
              "name": "callback",
              "desc": "Called with `(host, port)` when the server is ready. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 587
          },
          "is_method": true,
          "signature": "HttpServer:_readRequest(sock: any, remoteAddr: string, remotePort: number, initialBuffer: string?) → (ServerRequest?, string)",
          "owner": "HttpServer",
          "desc": "Parse an incoming HTTP request from a client socket.\nReturns nil if the connection was closed before a full request arrived.\n\nIn the default mode, request bodies are buffered eagerly and exposed\nthrough `req.body`, `req.form`, and `req.multipart`. When\n`streamRequestBodies = true`, requests instead expose `req.bodyStream`\nalong with `req:readBody()`, `req:readForm()`, `req:readMultipart()`,\nand `req:readJson()` for on-demand buffering/decoding. Chunked\nrequest trailers are exposed on `req.trailers` once the body has\nbeen fully consumed.",
          "tags": [],
          "name": "_readRequest",
          "return_str": "(ServerRequest?, string)",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "ServerRequest?",
              "desc": ""
            },
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "any",
              "name": "sock",
              "desc": ""
            },
            {
              "lua_type": "string",
              "name": "remoteAddr",
              "desc": ""
            },
            {
              "lua_type": "number",
              "name": "remotePort",
              "desc": ""
            },
            {
              "lua_type": "string?",
              "name": "initialBuffer",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 934
          },
          "is_method": true,
          "signature": "HttpServer:_handleConnection(\n    client_sock: any,  -- The accepted client socket.\n    remoteAddr: string,  -- The peer IP address.\n    remotePort: number  -- The peer port.\n) → (\n    boolean  -- `true` when the connection was upgraded and the socket ownership has been transferred elsewhere. \n)",
          "owner": "HttpServer",
          "desc": "Handles one accepted client connection.\n\nThis may serve multiple requests over the same socket when keep-alive\nis in use. Unread streamed request bodies are drained automatically\nbefore reusing the connection.\n",
          "tags": [],
          "name": "_handleConnection",
          "return_str": "boolean",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "boolean",
              "desc": "`true` when the connection was upgraded and the socket ownership has been transferred elsewhere. "
            }
          ],
          "params": [
            {
              "lua_type": "any",
              "name": "client_sock",
              "desc": "The accepted client socket."
            },
            {
              "lua_type": "string",
              "name": "remoteAddr",
              "desc": "The peer IP address."
            },
            {
              "lua_type": "number",
              "name": "remotePort",
              "desc": "The peer port."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 1023
          },
          "is_method": true,
          "signature": "HttpServer:close() → ()",
          "owner": "HttpServer",
          "desc": "Stops the server by closing the listening socket.\n\nThis unblocks the [[HttpServer.listen]] call, allowing the server\nloop to exit cleanly.\n",
          "tags": [],
          "name": "close",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": []
        }
      ],
      "metamethods": [],
      "types": []
    }
  ]
}