On mac OS, puppy 1.5.0, when a POST endpoint returns an empty body, puppy throws an exception. This was not caught in the unit test because the /post test returns data. If i modify it slightly to return an empty string...
diff --git a/tests/test.nim b/tests/test.nim
index 0794690..9c3a64b 100644
--- a/tests/test.nim
+++ b/tests/test.nim
@@ -111,12 +111,12 @@ try:
let req = Request(
url: parseUrl("http://localhost:8080/post"),
verb: "post",
- body: "some data"
+ body: ""
)
let res = fetch(req)
doAssert ($req).startsWith("POST http://localhost:8080/post")
doAssert res.code == 200
- doAssert res.body == "some data"
+ doAssert res.body == ""
block:
# test post + gzip
I get the following:
/Users/sekao/Documents/puppy/tests/test.nim(116) test
/Users/sekao/Documents/puppy/src/puppy.nim(348) fetch
/Users/sekao/.choosenim/toolchains/nim-1.6.2/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
The error is happening on this line so it looks like it needs to check the string length before trying to copy. This code only runs on mac OS so it wouldn't affect other OSes, but there may be a similar problem elsewhere, i haven't checked.
% nim -v
Nim Compiler Version 1.6.2 [MacOSX: amd64]
Compiled at 2021-12-17
Copyright (c) 2006-2021 by Andreas Rumpf
active boot switches: -d:release
On mac OS, puppy 1.5.0, when a POST endpoint returns an empty body, puppy throws an exception. This was not caught in the unit test because the
/post
test returns data. If i modify it slightly to return an empty string...I get the following:
The error is happening on this line so it looks like it needs to check the string length before trying to copy. This code only runs on mac OS so it wouldn't affect other OSes, but there may be a similar problem elsewhere, i haven't checked.