fix'ed content-type and header sending on error