Send a redirection if the request contains a hostname which is not */ fully qualified, i.e. doesn't have a domain name appended. Some proxy */ servers like Netscape's allow this and access hosts from the local */ domain in this case. I think it is better to redirect to a FQDN, since */ these will later be found in the bookmarks files. */ The "ProxyDomain" directive determines what domain will be a
| 1173 | /* these will later be found in the bookmarks files. */ |
| 1174 | /* The "ProxyDomain" directive determines what domain will be appended */ |
| 1175 | static int proxy_needsdomain(request_rec *r, const char *url, const char *domain) |
| 1176 | { |
| 1177 | char *nuri; |
| 1178 | const char *ref; |
| 1179 | |
| 1180 | /* We only want to worry about GETs */ |
| 1181 | if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname) |
| 1182 | return DECLINED; |
| 1183 | |
| 1184 | /* If host does contain a dot already, or it is "localhost", decline */ |
| 1185 | if (strchr(r->parsed_uri.hostname, '.') != NULL /* has domain, or IPv4 literal */ |
| 1186 | || strchr(r->parsed_uri.hostname, ':') != NULL /* IPv6 literal */ |
| 1187 | || ap_cstr_casecmp(r->parsed_uri.hostname, "localhost") == 0) |
| 1188 | return DECLINED; /* host name has a dot already */ |
| 1189 | |
| 1190 | ref = apr_table_get(r->headers_in, "Referer"); |
| 1191 | |
| 1192 | /* Reassemble the request, but insert the domain after the host name */ |
| 1193 | /* Note that the domain name always starts with a dot */ |
| 1194 | r->parsed_uri.hostname = apr_pstrcat(r->pool, r->parsed_uri.hostname, |
| 1195 | domain, NULL); |
| 1196 | nuri = apr_uri_unparse(r->pool, |
| 1197 | &r->parsed_uri, |
| 1198 | APR_URI_UNP_REVEALPASSWORD); |
| 1199 | |
| 1200 | apr_table_setn(r->headers_out, "Location", nuri); |
| 1201 | ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01138) |
| 1202 | "Domain missing: %s sent to %s%s%s", r->uri, |
| 1203 | apr_uri_unparse(r->pool, &r->parsed_uri, |
| 1204 | APR_URI_UNP_OMITUSERINFO), |
| 1205 | ref ? " from " : "", ref ? ref : ""); |
| 1206 | |
| 1207 | return HTTP_MOVED_PERMANENTLY; |
| 1208 | } |
| 1209 | |
| 1210 | /* -------------------------------------------------------------- */ |
| 1211 | /* Invoke handler */ |
no test coverage detected