[TASK] Some adjustments for appserver.io compatibility (Revision 3)

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

Change-Id: Ibe212ed18ca7da1acb73e85470d893d86fdb3632
Releases: master
Revision-Id: 51fd554548240d11b1bba0af74d400eb96f4fd4d