I was not having the exit trap and the sleep+kill, I don't really get why it is necessary to have these. Looks a bit inefficient to me having a sleep and to kill your own process. But I am not really a bash expert.
>
> which of course does not make sense... can you try if this works? I'm guessing your script probably looks pretty much like this already...
>
> #!/bin/bash
> timeout=10
> trap "exit 0" QUIT
> {
> sleep $timeout
> kill -3 $$ 2>/dev/null
> } &
> read -r input
> exit_code=$?
> if [ ${exit_code} -eq 0 ]; then
> echo -n -e "HTTP/1.1 200 OK\r\n"
> echo -n -e "Content-Length: 0\r\n"
> echo -n -e "\r\n"
> fi
> exit 0