RE: how to get http header in c extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Hi!
> hi all
> I want to get specific http header key-value in my c extension.
> How should I do ? Thanks

You can access HTTP header information via $_SERVER. Searchingthrough PHP's codebase for an example of this gave me:http://lxr.php.net/xref/PHP_7_0/ext/phar/phar_object.c#61
>From there, it's not too hard to see how to do it... For example:
HashTable *_SERVER;zval *data;
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_UNDEF) {	return;}
_SERVER = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);
data = zend_hash_str_find(_SERVER, "CONTENT_TYPE", sizeof("CONTENT_TYPE")-1);
if (data == NULL) {	php_printf("Is not set...\n");} else {	php_printf("%s\n", Z_STRVAL_P(data));}
Regards,Tom
 		 	   		  

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux