Add cgi case for headers parsing

To get Content-Type and X-Authentication-Token tonic.php uses raw headers that it gets from sapi specific functions. The patch adds support for CGI based environments.