Bugfix for setting return codes in accept handler

The HTTP return code must be set before any actual output is written,
otherwise it has no effect.