Fix HTTPRequest blocking indefinitely under certain circumstances

If a misbehaving server is ignoring our Connection: Close and the
reply does not contain a newline fgets() will block. Now the content
length is explicitly checked and only the needed bytes are read, instead
of relying on a proper EOF.