Apache_request_headers () vs $ _SERVER

As far as I can tell, apache_request_headers() provides the same information as $_SERVER , but with slightly different keys. Why would anyone use apache_request_headers() rather than just getting this information from $_SERVER ? I am working with PHP 5.3.18 with Apache on Centos. thank you

EDIT. identical data from $_SERVER and apache_request_headers()

 Jun 2 08:50:53 localhost httpd: HTTP_HOST: www.badobe.com Jun 2 08:50:53 localhost httpd: Host: www.badobe.com Jun 2 08:50:53 localhost httpd: HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 Jun 2 08:50:53 localhost httpd: User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT: */* Jun 2 08:50:53 localhost httpd: Accept: */* Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5 Jun 2 08:50:53 localhost httpd: Accept-Language: en-US,en;q=0.5 Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT_ENCODING: gzip, deflate Jun 2 08:50:53 localhost httpd: Accept-Encoding: gzip, deflate Jun 2 08:50:53 localhost httpd: HTTP_REFERER: http://www.badobe.com/demo/administrator/index.php?cid=3 Jun 2 08:50:53 localhost httpd: Referer: http://www.badobe.com/demo/administrator/index.php?cid=3 Jun 2 08:50:53 localhost httpd: HTTP_COOKIE: PHPSESSID=feg3ecd4rsefvd03mgg6qear21 Jun 2 08:50:53 localhost httpd: Cookie: PHPSESSID=feg3ecd4rsefvd03mgg6qear21 Jun 2 08:50:53 localhost httpd: HTTP_CONNECTION: keep-alive Jun 2 08:50:53 localhost httpd: Connection: keep-alive Jun 2 08:50:53 localhost httpd: HTTP_IF_MODIFIED_SINCE: Sun, 02 Jun 2013 15:48:42 GMT Jun 2 08:50:53 localhost httpd: If-Modified-Since: Sun, 02 Jun 2013 15:48:42 GMT Jun 2 08:50:53 localhost httpd: HTTP_CACHE_CONTROL: max-age=0 Jun 2 08:50:53 localhost httpd: Cache-Control: max-age=0 
+6
source share
3 answers

I would suggest that the function only works with Apache. but this is just a wild guess

Also, I would guess that the function returns ALL headers, where I think $ _SERVER contains a predefined set of headers

+3
source

Because apache_request_headers () returns an associative array of all the HTTP headers in the current request, where $ _ SERVER gives more than

  • Title Details
  • Path Details
  • script location
+2
source

apache_request_headers not fully (fully) migrated, and $_SERVER not fully completed. In particular, $_SERVER never contains an Authorization header, regardless of whether PHP can handle its value internally or not.

Since 5.4.0 apache_request_headers been fixed to also show all headers in CGI deployments.

+2
source

Source: https://habr.com/ru/post/946348/


All Articles