Skip to content

Commit

Permalink
Expose asynchttpserver maxBody setting
Browse files Browse the repository at this point in the history
This commit exposes the maxBody setting of asynchttpserver.
The default value is 8388608, which is about 8MB and is taken from the nim documentation.
  • Loading branch information
noirscape authored and dom96 committed Apr 28, 2023
1 parent 9403126 commit 88dad03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jester.nim
Expand Up @@ -420,7 +420,7 @@ proc handleRequest(jes: Jester, httpReq: NativeRequest): Future[void] =

proc newSettings*(
port = Port(5000), staticDir = getCurrentDir() / "public",
appName = "", bindAddr = "", reusePort = false,
appName = "", bindAddr = "", reusePort = false, maxBody = 8388608,
futureErrorHandler: proc (fut: Future[void]) {.closure, gcsafe.} = nil
): Settings =
result = Settings(
Expand All @@ -429,6 +429,7 @@ proc newSettings*(
port: port,
bindAddr: bindAddr,
reusePort: reusePort,
maxBody: maxBody,
futureErrorHandler: futureErrorHandler
)

Expand Down Expand Up @@ -530,7 +531,7 @@ proc serve*(
httpbeast.initSettings(self.settings.port, self.settings.bindAddr, self.settings.numThreads)
)
else:
self.httpServer = newAsyncHttpServer(reusePort=self.settings.reusePort)
self.httpServer = newAsyncHttpServer(reusePort=self.settings.reusePort, maxBody=self.settings.maxBody)
let serveFut = self.httpServer.serve(
self.settings.port,
proc (req: asynchttpserver.Request): Future[void] {.gcsafe, closure.} =
Expand Down
1 change: 1 addition & 0 deletions jester/private/utils.nim
Expand Up @@ -16,6 +16,7 @@ type
port*: Port
bindAddr*: string
reusePort*: bool
maxBody*: int
futureErrorHandler*: proc (fut: Future[void]) {.closure, gcsafe.}
numThreads*: int # Only available with Httpbeast (`useHttpBeast = true`)

Expand Down

0 comments on commit 88dad03

Please sign in to comment.