fix "can't set headers" exception

see discussion in #113