Use the mainResponse for headerSent check
Merge pull request #17 from ShortSharpCode/header-race-2

Use the mainResponse for headersSent check