I hate myself ...
finally working, still in debug mode
added trailing headers support and extended POST method
extended send_error method and removed debugging outputs