http: remove BUG_ON(1) statement

Remove BUG_ON(1) statement that was a leftover from debugging.

Bug #1189
Bug #1212
htp: make htp state handling function more robust

Also, fix wrong cast that worked only by luck.