MCPcopy Index your code
hub / github.com/apache/httpd / ap_get_server_name

Function ap_get_server_name

server/core.c:1145–1180  ·  view source on GitHub ↗

There are two options regarding what the "name" of a server is. The * "canonical" name as defined by ServerName and Port, or the "client's * name" as supplied by a possible Host: header or full URI. * * The DNS option to UseCanonicalName causes this routine to do a * reverse lookup on the local IP address of the connection and use * that for the ServerName. This makes its value more reliabl

Source from the content-addressed store, hash-verified

1143 * -- fanf 1998-10-03
1144 */
1145AP_DECLARE(const char *) ap_get_server_name(request_rec *r)
1146{
1147 conn_rec *conn = r->connection;
1148 core_dir_config *d;
1149 const char *retval;
1150
1151 d = (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
1152
1153 switch (d->use_canonical_name) {
1154 case USE_CANONICAL_NAME_ON:
1155 retval = r->server->server_hostname;
1156 break;
1157 case USE_CANONICAL_NAME_DNS:
1158 if (conn->local_host == NULL) {
1159 if (apr_getnameinfo(&conn->local_host,
1160 conn->local_addr, 0) != APR_SUCCESS)
1161 conn->local_host = apr_pstrdup(conn->pool,
1162 r->server->server_hostname);
1163 else {
1164 ap_str_tolower(conn->local_host);
1165 }
1166 }
1167 retval = conn->local_host;
1168 break;
1169 case USE_CANONICAL_NAME_OFF:
1170 case USE_CANONICAL_NAME_UNSET:
1171 retval = r->hostname ? r->hostname : r->server->server_hostname;
1172 break;
1173 default:
1174 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00109)
1175 "ap_get_server_name: Invalid UCN Option somehow");
1176 retval = "localhost";
1177 break;
1178 }
1179 return retval;
1180}
1181
1182/*
1183 * Get the current server name from the request for the purposes

Callers 15

cache_canonicalise_keyFunction · 0.85
copy_uri_componentsFunction · 0.85
xlate_nameFunction · 0.85
safe_refererFunction · 0.85
balancer_display_pageFunction · 0.85
balancer_handlerFunction · 0.85
ajp_marshal_into_msgbFunction · 0.85
ap_proxy_create_hdrbrgdFunction · 0.85
mva_translateFunction · 0.85
mod_rewrite.cFile · 0.85
show_server_settingsFunction · 0.85

Calls 2

ap_str_tolowerFunction · 0.85

Tested by

no test coverage detected