Virtual Host Package
Collaboration diagram for Virtual Host Package:


typedef int(* ap_vhost_iterate_conn_cb) (void *baton, conn_rec *conn, server_rec *s)


void ap_init_vhost_config (apr_pool_t *p)
void ap_fini_vhost_config (apr_pool_t *p, server_rec *main_server)
const char * ap_parse_vhost_addrs (apr_pool_t *p, const char *hostname, server_rec *s)
const char * ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, const char *arg)
int ap_vhost_iterate_given_conn (conn_rec *conn, ap_vhost_iterate_conn_cb func_cb, void *baton)
void ap_update_vhost_given_ip (conn_rec *conn)
void ap_update_vhost_from_headers (request_rec *r)
int ap_update_vhost_from_headers_ex (request_rec *r, int require_match)
int ap_matches_request_vhost (request_rec *r, const char *host, apr_port_t port)

Detailed Description

Typedef Documentation

◆ ap_vhost_iterate_conn_cb

typedef int(* ap_vhost_iterate_conn_cb) (void *baton, conn_rec *conn, server_rec *s)

Callback function for every Name Based Virtual Host.

batonOpaque user object
connThe current Connection
sThe current Server
See also
0 on success, any non-zero return will stop the iteration.

Function Documentation

◆ ap_fini_vhost_config()

void ap_fini_vhost_config ( apr_pool_t p,
server_rec main_server 

called after the config has been read to compile the tables needed to do the run-time vhost lookups

pThe pool to allocate out of
main_serverThe start of the virtual host list

◆ ap_init_vhost_config()

void ap_init_vhost_config ( apr_pool_t p)

called before any config is read

pPool to allocate out of

◆ ap_matches_request_vhost()

int ap_matches_request_vhost ( request_rec r,
const char *  host,
apr_port_t  port 

Match the host in the header with the hostname of the server for this request.

rThe current request
hostThe hostname in the headers
portThe port from the headers
return 1 if the host:port matches any of the aliases of r->server, return 0 otherwise

◆ ap_parse_vhost_addrs()

const char* ap_parse_vhost_addrs ( apr_pool_t p,
const char *  hostname,
server_rec s 

handle addresses in "<VirtualHost>" statement

pThe pool to allocate out of
hostnameThe hostname in the VirtualHost statement
sThe list of Virtual Hosts.

◆ ap_set_name_virtual_host()

const char* ap_set_name_virtual_host ( cmd_parms cmd,
void *  dummy,
const char *  arg 

handle NameVirtualHost directive

cmdCommand Parameters structure
arga host of the form "<address>[:port]"

◆ ap_update_vhost_from_headers()

void ap_update_vhost_from_headers ( request_rec r)

ap_update_vhost_given_ip is never enough, and this is always called after the headers have been read. It may change r->server.

rThe current request

◆ ap_update_vhost_from_headers_ex()

int ap_update_vhost_from_headers_ex ( request_rec r,
int  require_match 

Updates r->server with the best name-based virtual host match, within the chain of matching virtual hosts selected by ap_update_vhost_given_ip.

rThe current request
require_match1 to return an HTTP error if the requested hostname is not explicitly matched to a VirtualHost.
return HTTP_OK unless require_match was specified and the requested hostname did not match any ServerName, ServerAlias, or VirtualHost address-spec.

◆ ap_update_vhost_given_ip()

void ap_update_vhost_given_ip ( conn_rec conn)

given an ip address only, give our best guess as to what vhost it is

connThe current connection

◆ ap_vhost_iterate_given_conn()

int ap_vhost_iterate_given_conn ( conn_rec conn,
ap_vhost_iterate_conn_cb  func_cb,
void *  baton 

For every virtual host on this connection, call func_cb.

connThe current connection
func_cbFunction called for every Name Based Virtual Host for this connection.
batonOpaque object passed to func_cb.
The return value from func_cb.
If func_cb returns non-zero, the function will return at this point, and not continue iterating the virtual hosts.