Fixed infinite loop that takes over the CPU during request handling

* Prevented the infinite loop in HTTP header parser
* Fixed invalid typecasts in GenericConnection
* Fixed typo in the comment
Thanks to the warning about `int`/`ssize_t` above, I decided to check the lines around.