- if (SUCCESS == zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv)) {
- FOREACH_KEYLEN(pos, *hsv, key, keylen, idx) {
- if (key && keylen > 6 && !strncmp(key, "HTTP_", 5)) {
- zval **header, *orig;
-
- key += 5;
- keylen -= 6;
- if (prettify) {
- key = pretty_key(estrndup(key, keylen), keylen, 1, 1);
- }
-
- zend_hash_get_current_data_ex(Z_ARRVAL_PP(hsv), (void *) &header, &pos);
-
- orig = *header;
- convert_to_string_ex(header);
- add_assoc_stringl(&array, key, Z_STRVAL_PP(header), Z_STRLEN_PP(header), 1);
- if (orig != *header) {
- zval_ptr_dtor(header);
- }
-
- if (prettify) {
- efree(key);
+
+ if (SUCCESS == zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv) && Z_TYPE_PP(hsv) == IS_ARRAY) {
+ FOREACH_KEY(pos, *hsv, key) {
+ if (key.type == HASH_KEY_IS_STRING && key.len > 6 && !strncmp(key.str, "HTTP_", 5)) {
+ key.len -= 5;
+ key.str = pretty_key(estrndup(key.str + 5, key.len - 1), key.len - 1, 1, 1);
+
+ zend_hash_get_current_data_ex(Z_ARRVAL_PP(hsv), (void *) &header, &pos);
+ ZVAL_ADDREF(*header);
+ zend_hash_add(HTTP_G->request.headers, key.str, key.len, (void *) header, sizeof(zval *), NULL);
+
+ efree(key.str);