From: Bill Stoddard Date: Tue, 12 Feb 2002 17:41:35 +0000 (+0000) Subject: Out foul tabs. No function change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b92180257f6680e39e8b03f3631552a9cb4e3d5;p=apache Out foul tabs. No function change. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93375 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 4c8d26d2a5..3f23747eb2 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -87,29 +87,29 @@ static int alias_match(const char *uri, const char *alias_fakename) const char *aliasp = alias_fakename, *urip = uri; while (aliasp < end_fakename) { - if (*aliasp == '/') { - /* any number of '/' in the alias matches any number in - * the supplied URI, but there must be at least one... - */ - if (*urip != '/') - return 0; - - while (*aliasp == '/') - ++aliasp; - while (*urip == '/') - ++urip; - } - else { - /* Other characters are compared literally */ - if (*urip++ != *aliasp++) - return 0; - } + if (*aliasp == '/') { + /* any number of '/' in the alias matches any number in + * the supplied URI, but there must be at least one... + */ + if (*urip != '/') + return 0; + + while (*aliasp == '/') + ++aliasp; + while (*urip == '/') + ++urip; + } + else { + /* Other characters are compared literally */ + if (*urip++ != *aliasp++) + return 0; + } } /* Check last alias path component matched all the way */ if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/') - return 0; + return 0; /* Return number of characters from URI which matched (may be * greater than length of alias, since we may have matched @@ -140,26 +140,26 @@ static int proxy_detect(request_rec *r) /* Ick... msvc (perhaps others) promotes ternary short results to int */ if (conf->req && r->parsed_uri.scheme) { - /* but it might be something vhosted */ - if (!(r->parsed_uri.hostname - && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r)) - && ap_matches_request_vhost(r, r->parsed_uri.hostname, - (apr_port_t)(r->parsed_uri.port_str ? r->parsed_uri.port - : ap_default_port(r))))) { - r->proxyreq = PROXYREQ_PROXY; - r->uri = r->unparsed_uri; - r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL); - r->handler = "proxy-server"; + /* but it might be something vhosted */ + if (!(r->parsed_uri.hostname + && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r)) + && ap_matches_request_vhost(r, r->parsed_uri.hostname, + (apr_port_t)(r->parsed_uri.port_str ? r->parsed_uri.port + : ap_default_port(r))))) { + r->proxyreq = PROXYREQ_PROXY; + r->uri = r->unparsed_uri; + r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL); + r->handler = "proxy-server"; } } /* We need special treatment for CONNECT proxying: it has no scheme part */ else if (conf->req && r->method_number == M_CONNECT - && r->parsed_uri.hostname - && r->parsed_uri.port_str) { - r->proxyreq = PROXYREQ_PROXY; - r->uri = r->unparsed_uri; - r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL); - r->handler = "proxy-server"; + && r->parsed_uri.hostname + && r->parsed_uri.port_str) { + r->proxyreq = PROXYREQ_PROXY; + r->uri = r->unparsed_uri; + r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL); + r->handler = "proxy-server"; } return DECLINED; } @@ -173,10 +173,10 @@ static int proxy_trans(request_rec *r) struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts; if (r->proxyreq) { - /* someone has already set up the proxy, it was possibly ourselves - * in proxy_detect - */ - return OK; + /* someone has already set up the proxy, it was possibly ourselves + * in proxy_detect + */ + return OK; } /* XXX: since r->uri has been manipulated already we're not really @@ -186,7 +186,7 @@ static int proxy_trans(request_rec *r) for (i = 0; i < conf->aliases->nelts; i++) { len = alias_match(r->uri, ent[i].fake); - + if (len > 0) { if ((ent[i].real[0] == '!' ) && ( ent[i].real[1] == 0 )) { return DECLINED; @@ -197,7 +197,7 @@ static int proxy_trans(request_rec *r) r->handler = "proxy-server"; r->proxyreq = PROXYREQ_REVERSE; return OK; - } + } } return DECLINED; } @@ -211,9 +211,9 @@ static int proxy_walk(request_rec *r) ap_conf_vector_t *entry_config; proxy_dir_conf *entry_proxy; int num_sec = sconf->sec_proxy->nelts; - /* XXX: shouldn't we use URI here? Canonicalize it first? - * Pass over "proxy:" prefix - */ + /* XXX: shouldn't we use URI here? Canonicalize it first? + * Pass over "proxy:" prefix + */ const char *proxyname = r->filename + 6; int j; @@ -273,19 +273,19 @@ static int proxy_fixup(request_rec *r) int access_status; if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) - return DECLINED; + return DECLINED; /* XXX: Shouldn't we try this before we run the proxy_walk? */ url = &r->filename[6]; /* canonicalise each specific scheme */ if ((access_status = proxy_run_canon_handler(r, url))) { - return access_status; + return access_status; } p = strchr(url, ':'); if (p == NULL || p == url) - return HTTP_BAD_REQUEST; + return HTTP_BAD_REQUEST; return OK; /* otherwise; we've done the best we can */ } @@ -303,29 +303,29 @@ static int proxy_needsdomain(request_rec *r, const char *url, const char *domain /* We only want to worry about GETs */ if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname) - return DECLINED; + return DECLINED; /* If host does contain a dot already, or it is "localhost", decline */ if (strchr(r->parsed_uri.hostname, '.') != NULL || strcasecmp(r->parsed_uri.hostname, "localhost") == 0) - return DECLINED; /* host name has a dot already */ + return DECLINED; /* host name has a dot already */ ref = apr_table_get(r->headers_in, "Referer"); /* Reassemble the request, but insert the domain after the host name */ /* Note that the domain name always starts with a dot */ r->parsed_uri.hostname = apr_pstrcat(r->pool, r->parsed_uri.hostname, - domain, NULL); + domain, NULL); nuri = apr_uri_unparse(r->pool, - &r->parsed_uri, - APR_URI_UNP_REVEALPASSWORD); + &r->parsed_uri, + APR_URI_UNP_REVEALPASSWORD); apr_table_set(r->headers_out, "Location", nuri); ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, 0, r, - "Domain missing: %s sent to %s%s%s", r->uri, - apr_uri_unparse(r->pool, &r->parsed_uri, - APR_URI_UNP_OMITUSERINFO), - ref ? " from " : "", ref ? ref : ""); + "Domain missing: %s sent to %s%s%s", r->uri, + apr_uri_unparse(r->pool, &r->parsed_uri, + APR_URI_UNP_OMITUSERINFO), + ref ? " from " : "", ref ? ref : ""); return HTTP_MOVED_PERMANENTLY; } @@ -349,59 +349,59 @@ static int proxy_handler(request_rec *r) /* is this for us? */ if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) - return DECLINED; + return DECLINED; /* handle max-forwards / OPTIONS / TRACE */ if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) { - maxfwd = strtol(str, NULL, 10); - if (maxfwd < 1) { + maxfwd = strtol(str, NULL, 10); + if (maxfwd < 1) { switch (r->method_number) { case M_TRACE: { - int access_status; - r->proxyreq = PROXYREQ_NONE; - if ((access_status = ap_send_http_trace(r))) - ap_die(access_status, r); - else - ap_finalize_request_protocol(r); - return OK; + int access_status; + r->proxyreq = PROXYREQ_NONE; + if ((access_status = ap_send_http_trace(r))) + ap_die(access_status, r); + else + ap_finalize_request_protocol(r); + return OK; } case M_OPTIONS: { - int access_status; - r->proxyreq = PROXYREQ_NONE; - if ((access_status = ap_send_http_options(r))) - ap_die(access_status, r); - else - ap_finalize_request_protocol(r); - return OK; + int access_status; + r->proxyreq = PROXYREQ_NONE; + if ((access_status = ap_send_http_options(r))) + ap_die(access_status, r); + else + ap_finalize_request_protocol(r); + return OK; } - default: { - return ap_proxyerror(r, HTTP_BAD_GATEWAY, - "Max-Forwards has reached zero - proxy loop?"); - } + default: { + return ap_proxyerror(r, HTTP_BAD_GATEWAY, + "Max-Forwards has reached zero - proxy loop?"); } - } - maxfwd = (maxfwd > 0) ? maxfwd - 1 : 0; + } + } + maxfwd = (maxfwd > 0) ? maxfwd - 1 : 0; } else { - /* set configured max-forwards */ - maxfwd = conf->maxfwd; + /* set configured max-forwards */ + maxfwd = conf->maxfwd; } apr_table_set(r->headers_in, "Max-Forwards", - apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0)); + apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0)); if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) - return rc; + return rc; url = r->filename + 6; p = strchr(url, ':'); if (p == NULL) - return HTTP_BAD_REQUEST; + return HTTP_BAD_REQUEST; /* If the host doesn't have a domain name, add one and redirect. */ if (conf->domain != NULL) { - rc = proxy_needsdomain(r, url, conf->domain); - if (ap_is_HTTP_REDIRECT(rc)) - return HTTP_MOVED_PERMANENTLY; + rc = proxy_needsdomain(r, url, conf->domain); + if (ap_is_HTTP_REDIRECT(rc)) + return HTTP_MOVED_PERMANENTLY; } *p = '\0'; @@ -413,40 +413,40 @@ static int proxy_handler(request_rec *r) /* we only know how to handle communication to a proxy via http */ /*if (strcasecmp(scheme, "http") == 0) */ { - int ii; - struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts; + int ii; + struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts; - for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) { - direct_connect = list[ii].matcher(&list[ii], r); - } + for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) { + direct_connect = list[ii].matcher(&list[ii], r); + } #if DEBUGGING - ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r, - (direct_connect) ? "NoProxy for %s" : "UseProxy for %s", - r->uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r, + (direct_connect) ? "NoProxy for %s" : "UseProxy for %s", + r->uri); #endif } /* firstly, try a proxy, unless a NoProxy directive is active */ if (!direct_connect) { - for (i = 0; i < proxies->nelts; i++) { + for (i = 0; i < proxies->nelts; i++) { p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */ - if (strcmp(ents[i].scheme, "*") == 0 || - (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) || - (p2 != NULL && - strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) { - - /* handle the scheme */ - ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, - "Trying to run scheme_handler against proxy"); - access_status = proxy_run_scheme_handler(r, conf, url, ents[i].hostname, ents[i].port); - - /* an error or success */ - if (access_status != DECLINED && access_status != HTTP_BAD_GATEWAY) { - return access_status; - } - /* we failed to talk to the upstream proxy */ - } - } + if (strcmp(ents[i].scheme, "*") == 0 || + (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) || + (p2 != NULL && + strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) { + + /* handle the scheme */ + ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, + "Trying to run scheme_handler against proxy"); + access_status = proxy_run_scheme_handler(r, conf, url, ents[i].hostname, ents[i].port); + + /* an error or success */ + if (access_status != DECLINED && access_status != HTTP_BAD_GATEWAY) { + return access_status; + } + /* we failed to talk to the upstream proxy */ + } + } } /* otherwise, try it direct */ @@ -456,13 +456,13 @@ static int proxy_handler(request_rec *r) /* handle the scheme */ ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, - "Trying to run scheme_handler"); + "Trying to run scheme_handler"); access_status = proxy_run_scheme_handler(r, conf, url, NULL, 0); if (DECLINED == access_status) { ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, - "Neither CONNECT, HTTP or FTP for %s", - r->uri); - return HTTP_FORBIDDEN; + "Neither CONNECT, HTTP or FTP for %s", + r->uri); + return HTTP_FORBIDDEN; } return access_status; } @@ -563,26 +563,26 @@ static const char * f = apr_pstrdup(cmd->pool, f1); p = strchr(r, ':'); if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') { - return "ProxyRemote: Bad syntax for a remote proxy server"; + return "ProxyRemote: Bad syntax for a remote proxy server"; } else { - scheme[p-r] = 0; + scheme[p-r] = 0; } q = strchr(p + 3, ':'); if (q != NULL) { - if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) - return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; - *q = '\0'; + if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) + return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; + *q = '\0'; } else - port = -1; + port = -1; *p = '\0'; if (strchr(f, ':') == NULL) - ap_str_tolower(f); /* lowercase scheme */ + ap_str_tolower(f); /* lowercase scheme */ ap_str_tolower(p + 3); /* lowercase hostname */ if (port == -1) { - port = apr_uri_default_port_for_scheme(scheme); + port = apr_uri_default_port_for_scheme(scheme); } new = apr_array_push(conf->proxies); @@ -601,19 +601,19 @@ static const char * (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module); struct proxy_alias *new; if (r!=NULL && cmd->path == NULL ) { - new = apr_array_push(conf->aliases); - new->fake = f; - new->real = r; - } else if (r==NULL && cmd->path != NULL) { + new = apr_array_push(conf->aliases); + new->fake = f; + new->real = r; + } else if (r==NULL && cmd->path != NULL) { new = apr_array_push(conf->aliases); new->fake = cmd->path; new->real = f; - } else { + } else { if ( r== NULL) - return "ProxyPass needs a path when not defined in a location"; + return "ProxyPass needs a path when not defined in a location"; else - return "ProxyPass can not have a path when defined in a location"; - } + return "ProxyPass can not have a path when defined in a location"; + } return NULL; } @@ -626,22 +626,22 @@ static const char * struct proxy_alias *new; conf = (proxy_server_conf *)ap_get_module_config(s->module_config, - &proxy_module); + &proxy_module); if (r!=NULL && cmd->path == NULL ) { - new = apr_array_push(conf->raliases); - new->fake = f; - new->real = r; + new = apr_array_push(conf->raliases); + new->fake = f; + new->real = r; } else if (r==NULL && cmd->path != NULL) { - new = apr_array_push(conf->raliases); - new->fake = cmd->path; - new->real = f; + new = apr_array_push(conf->raliases); + new->fake = cmd->path; + new->real = f; } else { - if ( r == NULL) - return "ProxyPassReverse needs a path when not defined in a location"; - else - return "ProxyPassReverse can not have a path when defined in a location"; + if ( r == NULL) + return "ProxyPassReverse needs a path when not defined in a location"; + else + return "ProxyPassReverse can not have a path when defined in a location"; } - + return NULL; } @@ -659,20 +659,20 @@ static const char * /* Don't duplicate entries */ for (i = 0; i < conf->noproxies->nelts; i++) { - if (apr_strnatcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */ - found = 1; - } + if (apr_strnatcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */ + found = 1; + } } if (!found) { - new = apr_array_push(conf->noproxies); - new->name = arg; - if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) { - new->addr = addr; - } - else { - new->addr = NULL; - } + new = apr_array_push(conf->noproxies); + new->name = arg; + if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) { + new->addr = addr; + } + else { + new->addr = NULL; + } } return NULL; } @@ -685,11 +685,11 @@ static const char * { server_rec *s = parms->server; proxy_server_conf *conf = - ap_get_module_config(s->module_config, &proxy_module); + ap_get_module_config(s->module_config, &proxy_module); int *New; if (!apr_isdigit(arg[0])) - return "AllowCONNECT: port number must be numeric"; + return "AllowCONNECT: port number must be numeric"; New = apr_array_push(conf->allowed_connect_ports); *New = atoi(arg); @@ -712,43 +712,43 @@ static const char * /* Don't duplicate entries */ for (i = 0; i < conf->dirconn->nelts; i++) { - if (strcasecmp(arg, list[i].name) == 0) - found = 1; + if (strcasecmp(arg, list[i].name) == 0) + found = 1; } if (!found) { - New = apr_array_push(conf->dirconn); + New = apr_array_push(conf->dirconn); New->name = apr_pstrdup(parms->pool, arg); - New->hostaddr = NULL; + New->hostaddr = NULL; if (ap_proxy_is_ipaddr(New, parms->pool)) { #if DEBUGGING - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Parsed addr %s", inet_ntoa(New->addr)); - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Parsed mask %s", inet_ntoa(New->mask)); #endif } else if (ap_proxy_is_domainname(New, parms->pool)) { - ap_str_tolower(New->name); + ap_str_tolower(New->name); #if DEBUGGING - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Parsed domain %s", New->name); #endif - } - else if (ap_proxy_is_hostname(New, parms->pool)) { - ap_str_tolower(New->name); + } + else if (ap_proxy_is_hostname(New, parms->pool)) { + ap_str_tolower(New->name); #if DEBUGGING - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Parsed host %s", New->name); #endif - } - else { - ap_proxy_is_word(New, parms->pool); + } + else { + ap_proxy_is_word(New, parms->pool); #if DEBUGGING - fprintf(stderr, "Parsed word %s\n", New->name); + fprintf(stderr, "Parsed word %s\n", New->name); #endif - } + } } return NULL; } @@ -760,7 +760,7 @@ static const char * ap_get_module_config(parms->server->module_config, &proxy_module); if (arg[0] != '.') - return "ProxyDomain: domain name must start with a dot."; + return "ProxyDomain: domain name must start with a dot."; psf->domain = arg; return NULL; @@ -804,7 +804,7 @@ static const char * ap_get_module_config(parms->server->module_config, &proxy_module); int s = atoi(arg); if (s < 512 && s != 0) { - return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default."; + return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default."; } psf->recv_buffer_size = s; @@ -819,7 +819,7 @@ static const char * ap_get_module_config(parms->server->module_config, &proxy_module); long s = atol(arg); if (s < 0) { - return "ProxyMaxForwards must be greater or equal to zero.."; + return "ProxyMaxForwards must be greater or equal to zero.."; } psf->maxfwd = s; @@ -858,8 +858,8 @@ static const char* else if (strcasecmp(arg, "Full") == 0) psf->viaopt = via_full; else { - return "ProxyVia must be one of: " - "off | on | full | block"; + return "ProxyVia must be one of: " + "off | on | full | block"; } psf->viaopt_set = 1; @@ -887,14 +887,14 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) const command_rec *thiscmd = cmd->cmd; const char *err = ap_check_cmd_context(cmd, - NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); if (err != NULL) { return err; } if (endp == NULL) { return apr_pstrcat(cmd->pool, cmd->cmd->name, - "> directive missing closing '>'", NULL); + "> directive missing closing '>'", NULL); } arg=apr_pstrndup(cmd->pool, arg, endp-arg); @@ -917,15 +917,15 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) * scheme? See proxy_fixup() */ if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); } else if (!strcmp(cmd->path, "~")) { - cmd->path = ap_getword_conf(cmd->pool, &arg); + cmd->path = ap_getword_conf(cmd->pool, &arg); if (!cmd->path) return " block must specify a path"; if (strncasecmp(cmd->path, "proxy:", 6)) cmd->path += 6; - r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); } /* initialize our config and fetch it */ @@ -934,7 +934,7 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf); if (errmsg != NULL) - return errmsg; + return errmsg; conf->r = r; conf->p = cmd->path; @@ -943,8 +943,8 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) ap_add_per_proxy_conf(cmd->server, new_dir_conf); if (*arg != '\0') { - return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, + "> arguments not (yet) supported.", NULL); } cmd->path = old_path;