[TASK] Some adjustments for appserver.io compatibility

This allows to influence the SAPI type and adds some checks when
sending headers.

Change-Id: Ibe212ed18ca7da1acb73e85470d893d86fdb3632
Releases: master