This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Description
When a file is sent to a route, the binary data is sent after the headers, but if the file is too big, then the collectLines throws a OutOfMemoryError.
The size of the file could be checked by reading the Content-Length header, but still, I don't believe that it should use that much heap.
StackTrace:
TestHTTP > testFile() STANDARD_ERROR
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at net.thesimpleteam.picohttp.PicoHTTP.listenForRequests(PicoHTTP.java:159)
at net.thesimpleteam.picohttp.PicoHTTP.lambda$run$6(PicoHTTP.java:114)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:228)
at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:802)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:246)
at net.thesimpleteam.picohttp.PicoHTTP.collectLines(PicoHTTP.java:184)
at net.thesimpleteam.picohttp.PicoHTTP.lambda$listenForRequests$8(PicoHTTP.java:140)
at net.thesimpleteam.picohttp.PicoHTTP$$Lambda$481/0x0000000800d3deb0.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
... 3 more