views:

115

answers:

3

I'm writing an Apache module and want to get a string with the Apache name version and other details. Much like what gets added to outgoing headers, e.g.:

Server: Apache/2.2.13 (Win32)

I've tried code like this:

apr_table_get(request_rec->headers_out,"Server")

But that doesn't seem to work. Is there an API call I haven't found or am I doomed to get version resource data from httpd.exe?

A: 

try this command

apache2 -v

should print out something like this

Server version: Apache/2.2.11 (Ubuntu)
Server built:   Mar  9 2010 21:05:51

most unix commands have a -v option

it looks like you are trying to get it from php, the exec command in php will let you run the command on the server

imightbeinatree at Cloudspace
I'm not running this from PHP. I don't want to start extra processes, and am looking to get this from the Apache API somewhere.
Stijn Sanders
A: 

I'm not sure about Apache modules, but for CGI scripts, the name of the current web server is stored in the SERVER_SOFTWARE environment variable. In Perl, for example, you would use $ENV{SERVER_SOFTWARE} to read it. In C you would use getenv ("SERVER_SOFTWARE").

In order to find out the server software, why not just grep through the Apache source codes to find where this is defined.

Doing this with Apache 1.3.41, I find that it is defined in a file called util_script.c on line 240 as follows:

ap_table_addn(e, "SERVER_SOFTWARE", ap_get_server_version());

It looks like there is a function called ap_get_server_version which returns the value as a string.

Kinopiko
nope, I've checked GetEnvironmentStrings, nothing like SERVER_SOFTWARE, or anything holding version info about Apache. Note that I am developing an Apache module, which is quite different than CGI.
Stijn Sanders
A: 

Found it: ap_get_server_version, my HTTPD2 API wrapper was missing this declaration

Stijn Sanders