Fixed error with content-type headers that contained a charset.

The content-type header is now split on semicolons, after which a character set may be defined. Previously whenever a character set was provided, the content-type was interpreted incorrectly.

Also added a simple error logging method to make errors properly visible.