Fixed serious bug causing incorrect HTTP response length