Loading modules/proxy/mod_proxy.c +6 −15 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ APR_HOOK_STRUCT( ) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport),(r,url,proxyhost,proxyport),DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port),(r,url,scheme,def_port),DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url),(r,url),DECLINED) /* Loading Loading @@ -205,6 +205,7 @@ static int proxy_trans(request_rec *r) static int proxy_fixup(request_rec *r) { char *url, *p; int access_status; if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) return DECLINED; Loading @@ -212,10 +213,9 @@ static int proxy_fixup(request_rec *r) url = &r->filename[6]; /* canonicalise each specific scheme */ if (strncasecmp(url, "http:", 5) == 0) return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT); else if (strncasecmp(url, "ftp:", 4) == 0) return ap_proxy_ftp_canon(r, url + 4, NULL, 0); if ((access_status = ap_run_proxy_canon_handler(r, url))) { return access_status; } p = strchr(url, ':'); if (p == NULL || p == url) Loading Loading @@ -279,7 +279,6 @@ static int proxy_handler(request_rec *r) int i, rc; int direct_connect = 0; const char *str; const char *pragma, *auth, *imstr; long maxfwd; /* is this for us? */ Loading Loading @@ -332,14 +331,6 @@ static int proxy_handler(request_rec *r) if (p == NULL) return HTTP_BAD_REQUEST; pragma = apr_table_get(r->headers_in, "Pragma"); auth = apr_table_get(r->headers_in, "Authorization"); imstr = apr_table_get(r->headers_in, "If-Modified-Since"); ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL, "Request for %s, pragma=%s, auth=%s, imstr=%s", url, pragma, auth, imstr); /* If the host doesn't have a domain name, add one and redirect. */ if (conf->domain != NULL) { rc = proxy_needsdomain(r, url, conf->domain); Loading modules/proxy/mod_proxy.h +5 −5 Original line number Diff line number Diff line Loading @@ -206,12 +206,13 @@ typedef struct { /* proxy_connect.c */ int ap_proxy_connect_canon(request_rec *r, char *url); int ap_proxy_connect_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); /* proxy_ftp.c */ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port); int ap_proxy_ftp_canon(request_rec *r, char *url); int ap_proxy_ftp_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *bb); Loading @@ -219,8 +220,7 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, /* proxy_http.c */ int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port); int ap_proxy_http_canon(request_rec *r, char *url); int ap_proxy_http_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); Loading @@ -232,7 +232,7 @@ void ap_proxy_c2hex(int ch, char *x); char *ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, int isenc); char *ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, int *port); char **passwordp, char **hostp, apr_port_t *port); const char *ap_proxy_date_canon(apr_pool_t *p, const char *x); apr_table_t *ap_proxy_read_headers(request_rec *r, request_rec *rp, char *buffer, int size, conn_rec *c); int ap_proxy_liststr(const char *list, const char *val); Loading @@ -255,7 +255,7 @@ void ap_proxy_reset_output_filters(conn_rec *c); AP_DECLARE_HOOK(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport)) AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port)) AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url)) #endif /*MOD_PROXY_H*/ modules/proxy/proxy_connect.c +17 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,18 @@ allowed_port(proxy_server_conf *conf, int port) return 0; } /* canonicalise CONNECT URLs. */ int ap_proxy_connect_canon(request_rec *r, char *url) { if (r->method_number != M_CONNECT) { return DECLINED; } return OK; } /* CONNECT handler */ int ap_proxy_connect_handler(request_rec *r, char *url, const char *proxyname, apr_port_t proxyport) { Loading @@ -122,6 +134,10 @@ int ap_proxy_connect_handler(request_rec *r, char *url, proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module); /* is this for us? */ if (r->method_number != M_CONNECT) { return DECLINED; } /* * Step One: Determine Who To Connect To Loading Loading @@ -388,6 +404,7 @@ int ap_proxy_connect_handler(request_rec *r, char *url, static void ap_proxy_connect_register_hook(apr_pool_t *p) { ap_hook_proxy_scheme_handler(ap_proxy_connect_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_proxy_canon_handler(ap_proxy_connect_canon, NULL, NULL, APR_HOOK_MIDDLE); } module AP_MODULE_DECLARE_DATA proxy_connect_module = { Loading modules/proxy/proxy_ftp.c +19 −10 Original line number Diff line number Diff line Loading @@ -113,14 +113,23 @@ static int ftp_check_string(const char *x) /* * Canonicalise ftp URLs. */ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port) int ap_proxy_ftp_canon(request_rec *r, char *url) { char *user, *password, *host, *path, *parms, *strp, sport[7]; apr_pool_t *p = r->pool; const char *err; int port; apr_port_t port, def_port; port = DEFAULT_FTP_PORT; /* */ if (strncasecmp(url, "ftp:", 4) == 0) { url += 4; } else { return DECLINED; } def_port = ap_default_port_for_scheme("ftp"); port = def_port; err = ap_proxy_canon_netloc(p, &url, &user, &password, &host, &port); if (err) return HTTP_BAD_REQUEST; Loading Loading @@ -170,7 +179,7 @@ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t /* now, rebuild URL */ if (port != DEFAULT_FTP_PORT) if (port != def_port) apr_snprintf(sport, sizeof(sport), ":%d", port); else sport[0] = '\0'; Loading modules/proxy/proxy_http.c +26 −11 Original line number Diff line number Diff line Loading @@ -68,11 +68,26 @@ module AP_MODULE_DECLARE_DATA proxy_http_module; * url is the URL starting with the first '/' * def_port is the default port for this scheme. */ int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port) int ap_proxy_http_canon(request_rec *r, char *url) { char *host, *path, *search, sport[7]; const char *err; int port; const char *scheme; apr_port_t port, def_port; /* ap_default_port_for_scheme() */ if (strncasecmp(url, "http:", 5) == 0) { url += 5; scheme = "http"; } else if (strncasecmp(url, "https:", 6) == 0) { url += 6; scheme = "https:"; } else { return DECLINED; } def_port = ap_default_port_for_scheme(scheme); /* do syntatic check. * We break the URL into host, port, path, search Loading Loading
modules/proxy/mod_proxy.c +6 −15 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ APR_HOOK_STRUCT( ) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport),(r,url,proxyhost,proxyport),DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port),(r,url,scheme,def_port),DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url),(r,url),DECLINED) /* Loading Loading @@ -205,6 +205,7 @@ static int proxy_trans(request_rec *r) static int proxy_fixup(request_rec *r) { char *url, *p; int access_status; if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) return DECLINED; Loading @@ -212,10 +213,9 @@ static int proxy_fixup(request_rec *r) url = &r->filename[6]; /* canonicalise each specific scheme */ if (strncasecmp(url, "http:", 5) == 0) return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT); else if (strncasecmp(url, "ftp:", 4) == 0) return ap_proxy_ftp_canon(r, url + 4, NULL, 0); if ((access_status = ap_run_proxy_canon_handler(r, url))) { return access_status; } p = strchr(url, ':'); if (p == NULL || p == url) Loading Loading @@ -279,7 +279,6 @@ static int proxy_handler(request_rec *r) int i, rc; int direct_connect = 0; const char *str; const char *pragma, *auth, *imstr; long maxfwd; /* is this for us? */ Loading Loading @@ -332,14 +331,6 @@ static int proxy_handler(request_rec *r) if (p == NULL) return HTTP_BAD_REQUEST; pragma = apr_table_get(r->headers_in, "Pragma"); auth = apr_table_get(r->headers_in, "Authorization"); imstr = apr_table_get(r->headers_in, "If-Modified-Since"); ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL, "Request for %s, pragma=%s, auth=%s, imstr=%s", url, pragma, auth, imstr); /* If the host doesn't have a domain name, add one and redirect. */ if (conf->domain != NULL) { rc = proxy_needsdomain(r, url, conf->domain); Loading
modules/proxy/mod_proxy.h +5 −5 Original line number Diff line number Diff line Loading @@ -206,12 +206,13 @@ typedef struct { /* proxy_connect.c */ int ap_proxy_connect_canon(request_rec *r, char *url); int ap_proxy_connect_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); /* proxy_ftp.c */ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port); int ap_proxy_ftp_canon(request_rec *r, char *url); int ap_proxy_ftp_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *bb); Loading @@ -219,8 +220,7 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, /* proxy_http.c */ int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port); int ap_proxy_http_canon(request_rec *r, char *url); int ap_proxy_http_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport); Loading @@ -232,7 +232,7 @@ void ap_proxy_c2hex(int ch, char *x); char *ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, int isenc); char *ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, int *port); char **passwordp, char **hostp, apr_port_t *port); const char *ap_proxy_date_canon(apr_pool_t *p, const char *x); apr_table_t *ap_proxy_read_headers(request_rec *r, request_rec *rp, char *buffer, int size, conn_rec *c); int ap_proxy_liststr(const char *list, const char *val); Loading @@ -255,7 +255,7 @@ void ap_proxy_reset_output_filters(conn_rec *c); AP_DECLARE_HOOK(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport)) AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port)) AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url)) #endif /*MOD_PROXY_H*/
modules/proxy/proxy_connect.c +17 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,18 @@ allowed_port(proxy_server_conf *conf, int port) return 0; } /* canonicalise CONNECT URLs. */ int ap_proxy_connect_canon(request_rec *r, char *url) { if (r->method_number != M_CONNECT) { return DECLINED; } return OK; } /* CONNECT handler */ int ap_proxy_connect_handler(request_rec *r, char *url, const char *proxyname, apr_port_t proxyport) { Loading @@ -122,6 +134,10 @@ int ap_proxy_connect_handler(request_rec *r, char *url, proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module); /* is this for us? */ if (r->method_number != M_CONNECT) { return DECLINED; } /* * Step One: Determine Who To Connect To Loading Loading @@ -388,6 +404,7 @@ int ap_proxy_connect_handler(request_rec *r, char *url, static void ap_proxy_connect_register_hook(apr_pool_t *p) { ap_hook_proxy_scheme_handler(ap_proxy_connect_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_proxy_canon_handler(ap_proxy_connect_canon, NULL, NULL, APR_HOOK_MIDDLE); } module AP_MODULE_DECLARE_DATA proxy_connect_module = { Loading
modules/proxy/proxy_ftp.c +19 −10 Original line number Diff line number Diff line Loading @@ -113,14 +113,23 @@ static int ftp_check_string(const char *x) /* * Canonicalise ftp URLs. */ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port) int ap_proxy_ftp_canon(request_rec *r, char *url) { char *user, *password, *host, *path, *parms, *strp, sport[7]; apr_pool_t *p = r->pool; const char *err; int port; apr_port_t port, def_port; port = DEFAULT_FTP_PORT; /* */ if (strncasecmp(url, "ftp:", 4) == 0) { url += 4; } else { return DECLINED; } def_port = ap_default_port_for_scheme("ftp"); port = def_port; err = ap_proxy_canon_netloc(p, &url, &user, &password, &host, &port); if (err) return HTTP_BAD_REQUEST; Loading Loading @@ -170,7 +179,7 @@ int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t /* now, rebuild URL */ if (port != DEFAULT_FTP_PORT) if (port != def_port) apr_snprintf(sport, sizeof(sport), ":%d", port); else sport[0] = '\0'; Loading
modules/proxy/proxy_http.c +26 −11 Original line number Diff line number Diff line Loading @@ -68,11 +68,26 @@ module AP_MODULE_DECLARE_DATA proxy_http_module; * url is the URL starting with the first '/' * def_port is the default port for this scheme. */ int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port) int ap_proxy_http_canon(request_rec *r, char *url) { char *host, *path, *search, sport[7]; const char *err; int port; const char *scheme; apr_port_t port, def_port; /* ap_default_port_for_scheme() */ if (strncasecmp(url, "http:", 5) == 0) { url += 5; scheme = "http"; } else if (strncasecmp(url, "https:", 6) == 0) { url += 6; scheme = "https:"; } else { return DECLINED; } def_port = ap_default_port_for_scheme(scheme); /* do syntatic check. * We break the URL into host, port, path, search Loading