Throw an Exception when the header is already been sent

Please see the details of the discussion at  issue #3990
@xinquanatcolezhu No. Just make the required change and make a new commit locally. Then push your updates to your github branch and this pull request will be automatically updated.

Please check the github help if you need more details.