MCPcopy Create free account
hub / github.com/apache/httpd / ap_get_useragent_host

Function ap_get_useragent_host

server/core.c:1036–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036AP_DECLARE(const char *) ap_get_useragent_host(request_rec *r,
1037 int type, int *str_is_ip)
1038{
1039 conn_rec *conn = r->connection;
1040 int hostname_lookups;
1041 int ignored_str_is_ip;
1042
1043 /* Guard here when examining the host before the read_request hook
1044 * has populated an r->useragent_addr
1045 */
1046 if (!r->useragent_addr || (r->useragent_addr == conn->client_addr)) {
1047 return ap_get_remote_host(conn, r->per_dir_config, type, str_is_ip);
1048 }
1049
1050 if (!str_is_ip) { /* caller doesn't want to know */
1051 str_is_ip = &ignored_str_is_ip;
1052 }
1053 *str_is_ip = 0;
1054
1055 hostname_lookups = ((core_dir_config *)
1056 ap_get_core_module_config(r->per_dir_config))
1057 ->hostname_lookups;
1058 if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) {
1059 hostname_lookups = HOSTNAME_LOOKUP_OFF;
1060 }
1061
1062 if (type != REMOTE_NOLOOKUP
1063 && r->useragent_host == NULL
1064 && (type == REMOTE_DOUBLE_REV
1065 || hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
1066
1067 if (apr_getnameinfo(&r->useragent_host, r->useragent_addr, 0)
1068 == APR_SUCCESS) {
1069 ap_str_tolower(r->useragent_host);
1070
1071 if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) {
1072 r->double_reverse = do_double_reverse(r->double_reverse,
1073 r->useragent_host,
1074 r->useragent_addr,
1075 r->pool);
1076 if (r->double_reverse != 1) {
1077 r->useragent_host = NULL;
1078 }
1079 }
1080 }
1081
1082 /* if failed, set it to the NULL string to indicate error */
1083 if (r->useragent_host == NULL) {
1084 r->useragent_host = "";
1085 }
1086 }
1087
1088 if (type == REMOTE_DOUBLE_REV) {
1089 r->double_reverse = do_double_reverse(r->double_reverse,
1090 r->useragent_host,
1091 r->useragent_addr, r->pool);
1092 if (r->double_reverse == -1) {
1093 return NULL;

Callers 11

ssl_var_lookupFunction · 0.85
host_check_authorizationFunction · 0.85
find_allowdenyFunction · 0.85
ajp_marshal_into_msgbFunction · 0.85
mod_rewrite.cFile · 0.85
match_headersFunction · 0.85
ssl_var_lookupFunction · 0.85
log_remote_hostFunction · 0.85
ap_add_common_varsFunction · 0.85
request_var_fnFunction · 0.85

Calls 4

ap_get_remote_hostFunction · 0.85
ap_str_tolowerFunction · 0.85
do_double_reverseFunction · 0.85

Tested by

no test coverage detected