fix bug where HTTP headers written after data has been sent
Merge pull request #47 from mozilla/bug-writeheader-after-data

fix bug where HTTP headers written after data has been sent