A simple example for those interested in writing Apache modules. Includes precise instructions on adding the module to your Apache. Also includes code to display the various module API data structures, a useful debugging aid.
Sample output:
The server fields:
srm_confname: "conf/srm.conf"
access_confname: "conf/access.conf"
server_admin: "root"
server_hostname: "anvil.acme.com"
port: 80
error_fname: "logs/error_log"
is_virtual: 0
host_addr: 0.0.0.0
host_port: 0
timeout: 400
keep_alive_timeout: 15
keep_alive: 5
path: null
pathlen: 0
names: null
virthost: null
The module config fields:
value: "yohoyoho"
The connection fields:
child_num: 0
aborted: 0
local_addr:
family: 2
port: 80
addr: 127.0.0.1
remote_addr:
family: 2
port: 33178
addr: 127.0.0.1
remote_ip: "127.0.0.1"
remote_host: "localhost"
remote_logname: null
user: null
auth_type: null
keepalive: 0
keptalive: 0
keepalives: 0
The request fields:
the_request: "GET /sample HTTP/1.0"
assbackwards: 0
proxyreq: 0
header_only: 0
protocol: "HTTP/1.0"
proto_num: 1000
hostname: "localhost"
hostlen: 0
status_line: null
status: 200
method: "GET"
method_number: 0
sent_bodyct: 0
bytes_sent: 0
headers_in: 4 (50)
0: "Connection" "Keep-Alive"
1: "User-Agent" "Mozilla/3.0 (X11; I; SunOS 5.5.1 sun4m)"
2: "Host" "localhost"
3: "Accept" "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"
headers_out: 0 (5)
err_headers_out: 0 (5)
subprocess_env: 0 (50)
notes: 0 (5)
content_type: null
handler: "sample-handler"
content_encoding: null
content_language: null
no_cache: 0
uri: "/sample"
filename: "/space/home/www/apache/htdocs/sample"
path_info: ""
args: null