From c0fe0a6dfbd45989f60bd754735359970b61c264 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Sat, 11 Nov 2000 18:13:04 +0000 Subject: [PATCH] proxy_ftp and proxy_http both compile now. Not tested because the rest of the proxy is still not compiling, but we are making progress. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86927 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.h | 2 +- modules/proxy/proxy_ftp.c | 33 +++++++++++++++++++-------------- modules/proxy/proxy_http.c | 6 +++++- modules/proxy/proxy_util.c | 5 +++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 16e5a7bad8..1036c6a365 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -277,6 +277,6 @@ int ap_proxy_doconnect(apr_socket_t *sock, char *host, apr_uint32_t port, reques int ap_proxy_garbage_init(server_rec *, apr_pool_t *); /* 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); -unsigned ap_proxy_bputs2(const char *data, BUFF *client, ap_cache_el *cache); +unsigned ap_proxy_bputs2(const char *data, apr_socket_t *client, ap_cache_el *cache); #endif /*MOD_PROXY_H*/ diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index 94c64e3d5f..68506bf4d0 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -310,7 +310,7 @@ static long int send_dir(BUFF *f, request_rec *r, ap_cache_el *c, char *cwd) "

Directory of " "%s/", site, path, site, path, site); - total_bytes_sent += ap_proxy_bputs2(buf, con->client, c); + total_bytes_sent += ap_proxy_bputs2(buf, con->client_socket, c); while ((dir = strchr(dir+1, '/')) != NULL) { @@ -321,7 +321,7 @@ static long int send_dir(BUFF *f, request_rec *r, ap_cache_el *c, char *cwd) ++reldir; /* print "path/" component */ apr_snprintf(buf, sizeof(buf), "%s/", path+1, reldir); - total_bytes_sent += ap_proxy_bputs2(buf, con->client, c); + total_bytes_sent += ap_proxy_bputs2(buf, con->client_socket, c); *dir = '/'; } /* If the caller has determined the current directory, and it differs */ @@ -331,7 +331,7 @@ static long int send_dir(BUFF *f, request_rec *r, ap_cache_el *c, char *cwd) } else { apr_snprintf(buf, sizeof(buf), "

\n(%s)\n
", cwd);
     }
-    total_bytes_sent += ap_proxy_bputs2(buf, con->client, c);
+    total_bytes_sent += ap_proxy_bputs2(buf, con->client_socket, c);
 
     while (!con->aborted) {
 	n = ap_bgets(buf, sizeof buf, f);
@@ -408,7 +408,8 @@ static long int send_dir(BUFF *f, request_rec *r, ap_cache_el  *c, char *cwd)
 	}
 
 	while (n && !r->connection->aborted) {
-	    w = ap_bwrite(con->client, &buf[o], n, &cntr);
+            cntr = n;
+	    w = apr_send(con->client_socket, &buf[o], &cntr);
 	    if (w <= 0)
 		break;
 	    n -= w;
@@ -416,12 +417,14 @@ static long int send_dir(BUFF *f, request_rec *r, ap_cache_el  *c, char *cwd)
 	}
     }
 
-    total_bytes_sent += ap_proxy_bputs2("

\n", con->client, c); - total_bytes_sent += ap_proxy_bputs2(ap_psignature("", r), con->client, c); - total_bytes_sent += ap_proxy_bputs2("\n", con->client, c); - - ap_bflush(con->client); + total_bytes_sent += ap_proxy_bputs2("
\n", con->client_socket, c); + total_bytes_sent += ap_proxy_bputs2(ap_psignature("", r), con->client_socket, c); + total_bytes_sent += ap_proxy_bputs2("\n", con->client_socket, c); +/* Flushing the actual socket doesn't make much sense, because we don't + * buffer it yet. + ap_flush(con->client); +*/ return total_bytes_sent; } @@ -492,7 +495,7 @@ int ap_proxy_ftp_handler(request_rec *r, ap_cache_el *c, char *url) char *pstr, dates[AP_RFC822_DATE_LEN]; char *npaddr; - apr_uint32_t npport; + apr_port_t npport; /* stuff for responses */ char resp[MAX_STRING_LEN]; @@ -867,10 +870,10 @@ int ap_proxy_ftp_handler(request_rec *r, ap_cache_el *c, char *url) ap_bclose(f); return HTTP_INTERNAL_SERVER_ERROR; } - apr_get_local_port(&npport, sock); - apr_get_local_ipaddr(&npaddr, sock); - apr_set_local_port(dsock, npport); - apr_set_local_ipaddr(dsock, npaddr); + apr_get_port(&npport, APR_LOCAL, sock); + apr_get_ipaddr(&npaddr, APR_LOCAL, sock); + apr_set_port(dsock, APR_LOCAL, npport); + apr_set_ipaddr(dsock, APR_LOCAL, npaddr); if (apr_setsocketopt(dsock, APR_SO_REUSEADDR, one) != APR_SUCCESS) { #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ @@ -1195,7 +1198,9 @@ int ap_proxy_ftp_handler(request_rec *r, ap_cache_el *c, char *url) cachefp = NULL; } +/* This is done by a filter now, so this can probably be removed cleanly. ap_bsetopt(r->connection->client, BO_BYTECT, &zero); +*/ r->sent_bodyct = 1; /* send body */ if (!r->header_only) { diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index b26a2ed131..8b690c05fe 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -455,11 +455,15 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url, if (!r->assbackwards) ap_rputs(CRLF, r); +/* We don't set byte count this way anymore. I think this can be removed + * cleanly now. ap_bsetopt(r->connection->client, BO_BYTECT, &zero); +*/ r->sent_bodyct = 1; /* Is it an HTTP/0.9 response? If so, send the extra data */ if (backasswards) { - ap_bwrite(r->connection->client, buffer, len, &cntr); + cntr = len; + apr_send(r->connection->client_socket, buffer, &cntr); cntr = len; if (cachefp && apr_write(cachefp, buffer, &cntr) != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 4b6b2139b5..6064d7d861 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1168,9 +1168,10 @@ int ap_proxy_send_hdr_line(void *p, const char *key, const char *value) } /* send a text line to one or two BUFF's; return line length */ -unsigned ap_proxy_bputs2(const char *data, BUFF *client, ap_cache_el *cache) +unsigned ap_proxy_bputs2(const char *data, apr_socket_t *client, ap_cache_el *cache) { - unsigned len = ap_bputs(data, client); + unsigned len = strlen(data); + apr_send(client, data, &len); apr_file_t *cachefp = NULL; if (ap_cache_el_data(cache, &cachefp) == APR_SUCCESS) -- 2.40.0