php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14362 getallheaders() possible bug.
Submitted: 2001-12-06 11:56 UTC Modified: 2001-12-06 17:51 UTC
From: ahristov at icygen dot com Assigned:
Status: Not a bug Package: Zlib related
PHP Version: 4.1.0 OS: Linux
Private report: No CVE-ID: None
 [2001-12-06 11:56 UTC] ahristov at icygen dot com
getallheaders is this :
PHP_FUNCTION(getallheaders)
{
    array_header *env_arr;
    table_entry *tenv;
    int i;
 
    if (array_init(return_value) == FAILURE) {
  RETURN_FALSE;
    }
    env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
    tenv = (table_entry *)env_arr->elts;
    for (i = 0; i < env_arr->nelts; ++i) {
  if (!tenv[i].key ||
   (PG(safe_mode) &&
    !strncasecmp(tenv[i].key, "authorization", 13))) {
   continue;
  }
  if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
   RETURN_FALSE;
  }
    }
}
Using the example from the docs :
<?php
$headers = getallheaders();
while (list ($header, $value) = each ($headers)) {
    echo "$header: $value<br>\n";
}
var_dump($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING']);
?>
I receive this :
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: bg
Connection: Keep-Alive
Host: vanity.masq
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
NULL 

I thought that to get if the browser has capability of encoding it must be in $HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING']. Why I decided that?
Snippet from zlib.c :
 if (ZLIBG(ob_gzhandler_status)==-1
  || zend_hash_find(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), (void **) &data)==FAILURE
  || Z_TYPE_PP(data)!=IS_ARRAY
  || zend_hash_find(Z_ARRVAL_PP(data), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), (void **) &a_encoding)==FAILURE) {
  /* return the original string */
  *return_value = **zv_string;
  zval_copy_ctor(return_value);
  ZLIBG(ob_gzhandler_status)=-1;
  return;
 }

The sniff from Naviscope :
GET http://myserver.masq/proxy/getall.php HTTP/1.1
Accept: */*
Accept-Language: bg
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: vanity.masq
Proxy-Connection: Keep-Alive
Pragma: no-cache

Regards,
Andrey Hristov

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-06 17:20 UTC] ahristov at icygen dot com
No bug. Naviscope does not resend Accept-Encoding header.
Sorry
 [2001-12-06 17:51 UTC] mfischer@php.net
Bogus then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 11:01:29 2024 UTC