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 XCode :)