From a43bb9db2e8261e3f86daee1b01382d8affe06e5 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Thu, 5 Apr 2001 18:53:04 +0000 Subject: [PATCH] Cleanup of dead functions within proxy_util.c. PR: Obtained from: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88732 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.c | 2 +- modules/proxy/mod_proxy.h | 7 +---- modules/proxy/proxy_http.c | 8 ++--- modules/proxy/proxy_util.c | 61 +++++--------------------------------- 4 files changed, 11 insertions(+), 67 deletions(-) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index ebf2b2f71f..e53ccc3541 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -412,7 +412,7 @@ static int proxy_handler(request_rec *r) return ap_proxy_http_handler(r, url, NULL, 0); #if FTP if (strcasecmp(scheme, "ftp") == 0) - return ap_proxy_ftp_handler(r, NULL, url); + return ap_proxy_ftp_handler(r, url); #endif else { ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 7a9bd7923a..885b46cb5e 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -156,7 +156,6 @@ struct proxy_alias { struct dirconn_entry { char *name; -// struct apr_sockaddr_t *addr; struct in_addr addr, mask; struct hostent *hostentry; int (*matcher) (struct dirconn_entry * This, request_rec *r); @@ -236,10 +235,8 @@ char *ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, int *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); -void ap_proxy_send_headers(request_rec *r, const char *respline, apr_table_t *hdrs); int ap_proxy_liststr(const char *list, const char *val); char *ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val); -void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength); int ap_proxy_hex2sec(const char *x); void ap_proxy_sec2hex(int t, char *y); const char *ap_proxy_host2addr(const char *host, struct hostent *reqhp); @@ -249,8 +246,6 @@ int ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p); int ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p); int ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p); int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr); -apr_status_t ap_proxy_doconnect(apr_socket_t *sock, char *host, apr_uint32_t port, request_rec *r); -/* This function is called by ap_table_do() for all header lines */ -int ap_proxy_send_hdr_line(void *p, const char *key, const char *value); +int ap_proxy_pre_http_connection(conn_rec *c); #endif /*MOD_PROXY_H*/ diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index 352c9f20d7..3abf583f68 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -217,7 +217,7 @@ int ap_proxy_http_handler(request_rec *r, char *url, } ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, - "proxy: connecting %s to %s:%d", url, uri.hostname, uri.port); + "proxy: HTTP connecting %s to %s:%d", url, uri.hostname, uri.port); /* do a DNS lookup for the destination host */ err = apr_sockaddr_info_get(&uri_addr, uri.hostname, APR_UNSPEC, uri.port, 0, p); @@ -398,10 +398,7 @@ int ap_proxy_http_handler(request_rec *r, char *url, */ /* set up the connection filters */ - ap_add_input_filter("HTTP_IN", NULL, NULL, origin); - ap_add_input_filter("CORE_IN", NULL, NULL, origin); - ap_add_output_filter("CORE", NULL, NULL, origin); - + ap_proxy_pre_http_connection(origin); /* strip connection listed hop-by-hop headers from the request */ /* even though in theory a connection: close coming from the client @@ -559,7 +556,6 @@ int ap_proxy_http_handler(request_rec *r, char *url, * filter chain */ - rp = make_fake_req(origin, r); apr_brigade_destroy(bb); diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 27acb4da11..d9d6f7fa5d 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -74,6 +74,7 @@ static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r); static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r); static int proxy_match_word(struct dirconn_entry *This, request_rec *r); static struct per_thread_data *get_per_thread_data(void); + /* already called in the knowledge that the characters are hex digits */ int ap_proxy_hex2c(const char *x) { @@ -465,35 +466,6 @@ apr_table_t *ap_proxy_read_headers(request_rec *r, request_rec *rr, char *buffer return headers_out; } -/* - * Sends response line and headers. Uses the client fd and the - * headers_out array from the passed request_rec to talk to the client - * and to properly set the headers it sends for things such as logging. - * - * A timeout should be set before calling this routine. - */ -void ap_proxy_send_headers(request_rec *r, const char *respline, apr_table_t *t) -{ - int i; - apr_socket_t *fp = r->connection->client_socket; - apr_table_entry_t *elts = (apr_table_entry_t *) apr_table_elts(t)->elts; - - char *temp = apr_pstrcat(r->pool, respline, CRLF, NULL); - apr_size_t len = strlen(temp); - apr_send(fp, temp, &len); - - for (i = 0; i < apr_table_elts(t)->nelts; ++i) { - if (elts[i].key != NULL) { - temp = apr_pstrcat(r->pool, elts[i].key, ": ", elts[i].val, CRLF, NULL); - apr_send(fp, temp, &len); - apr_table_addn(r->headers_out, elts[i].key, elts[i].val); - } - } - - len = 2; - apr_send(fp, CRLF, &len); -} - /* * list is a comma-separated list of case-insensitive tokens, with @@ -1109,34 +1081,15 @@ int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, return OK; } -apr_status_t ap_proxy_doconnect(apr_socket_t *sock, char *host, apr_uint32_t port, request_rec *r) +/* set up the minimal filter set */ +int ap_proxy_pre_http_connection(conn_rec *c) { - apr_status_t rv; - apr_sockaddr_t *destsa; - - rv = apr_sockaddr_info_get(&destsa, host, AF_INET, port, 0, r->pool); - if (rv == APR_SUCCESS) { - rv = apr_connect(sock, destsa); - } - else if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "proxy connect to %s port %d failed", host, port); - } - return rv; + ap_add_input_filter("HTTP_IN", NULL, NULL, c); + ap_add_input_filter("CORE_IN", NULL, NULL, c); + ap_add_output_filter("CORE", NULL, NULL, c); + return OK; } -/* This function is called by apr_table_do() for all header lines */ -/* (from proxy_http.c and proxy_ftp.c) */ -/* It is passed a table_do_args struct pointer and a MIME field and value pair */ -int ap_proxy_send_hdr_line(void *p, const char *key, const char *value) -{ - struct request_rec *r = (struct request_rec *)p; - if (key == NULL || value == NULL || value[0] == '\0') - return 1; - if (!r->assbackwards) - ap_rvputs(r, key, ": ", value, CRLF, NULL); - return 1; /* tell apr_table_do() to continue calling us for more headers */ -} #if defined WIN32 -- 2.40.0