1

我正在用 C/C++ 编写 PHP 扩展,我需要访问(只读)与请求一起发送的 http 标头。我尝试了 SAPI,但我失败了。:(

有没有可移植的解决方案(带有工作源代码)?

4

1 回答 1

2

This is the way you can traverse the list of http headers and output each:

zend_llist_position pos;
sapi_header_struct* h;
for (h = (sapi_header_struct*)zend_llist_get_first_ex(&SG(sapi_headers).headers, &pos);
     h;
     h = (sapi_header_struct*)zend_llist_get_next_ex(&SG(sapi_headers).headers, &pos))
{
    php_printf("SAPI! %.*s <br/>", h->header_len, h->header);
}
于 2013-10-27T08:51:49.257 回答