You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/11/18 04:17:22 UTC
cvs commit: apache-2.0/src/modules/proxy proxy_http.c proxy_util.c
rbb 00/11/17 19:17:21
Modified: src CHANGES
src/modules/proxy proxy_http.c proxy_util.c
Log:
More proxy fixes. There are still some bugs in this code, but this has
successfully proxied www.yahoo.com and www.ntrnet.net among other test
sites that I chose at random.
Revision Changes Path
1.338 +5 -0 apache-2.0/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-2.0/src/CHANGES,v
retrieving revision 1.337
retrieving revision 1.338
diff -u -r1.337 -r1.338
--- CHANGES 2000/11/17 17:26:31 1.337
+++ CHANGES 2000/11/18 03:17:21 1.338
@@ -1,4 +1,9 @@
Changes with Apache 2.0a8
+ *) More fixes for the proxy. There are still bugs in the proxy code,
+ but this has now proxied www.yahoo.com and www.ntrnet.net (my ISP)
+ successfully.
+ [Ryan Bloom]
+
*) Fix params for apr_getaddrinfo() call in connect proxy handler.
[Chuck Murcko]
1.23 +17 -7 apache-2.0/src/modules/proxy/proxy_http.c
Index: proxy_http.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_http.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- proxy_http.c 2000/11/17 00:19:30 1.22
+++ proxy_http.c 2000/11/18 03:17:21 1.23
@@ -361,7 +361,7 @@
AP_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(origin->output_filters, bb);
- ap_add_input_filter("HTTP", NULL, NULL, origin);
+ ap_add_input_filter("HTTP_IN", NULL, NULL, origin);
ap_add_input_filter("CORE_IN", NULL, NULL, origin);
ap_brigade_destroy(bb);
@@ -371,7 +371,8 @@
origin->remain = 0;
ap_get_brigade(origin->input_filters, bb, AP_MODE_BLOCKING);
- ap_bucket_read(AP_BRIGADE_FIRST(bb), (const char **)&buffer2, &len, AP_BLOCK_READ);
+ e = AP_BRIGADE_FIRST(bb);
+ ap_bucket_read(e, (const char **)&buffer2, &len, AP_BLOCK_READ);
if (len == -1) {
apr_close_socket(sock);
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
@@ -384,6 +385,8 @@
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Document contains no data");
}
+ AP_BUCKET_REMOVE(e);
+ ap_bucket_destroy(e);
/* Is it an HTTP/1 response? This is buggy if we ever see an HTTP/1.10 */
if (ap_checkmask(buffer2, "HTTP/#.# ###*")) {
@@ -403,6 +406,7 @@
buffer2[12] = '\0';
r->status = atoi(&buffer2[9]);
+
buffer2[12] = ' ';
r->status_line = apr_pstrdup(p, &buffer2[9]);
@@ -421,6 +425,9 @@
{
clear_connection(p, resp_hdrs); /* Strip Connection hdrs */
ap_cache_el_header_merge(c, resp_hdrs);
+ if (apr_table_get(resp_hdrs, "Content-type")) {
+ r->content_type = apr_pstrdup(r->pool, apr_table_get(resp_hdrs, "Content-type"));
+ }
}
if (conf->viaopt != via_off && conf->viaopt != via_block) {
@@ -480,7 +487,7 @@
#if 0
if (!r->assbackwards)
ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
-#endif
+
if (cachefp && apr_puts(apr_pstrcat(r->pool, "HTTP/1.0 ",
r->status_line, CRLF, NULL), cachefp) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
@@ -488,19 +495,20 @@
ap_proxy_cache_error(&c);
cachefp = NULL;
}
+#endif
+#if 0
/* send headers */
ap_cache_el_header_walk(c, ap_proxy_send_hdr_line, r, NULL);
-
+#endif
+/*
if (!r->assbackwards)
ap_rputs(CRLF, r);
-
+*/
r->sent_bodyct = 1;
/* Is it an HTTP/0.9 response? If so, send the extra data */
if (backasswards) {
cntr = len;
- apr_send(r->connection->client_socket, buffer, &cntr);
- cntr = len;
e = ap_bucket_create_heap(buffer, cntr, 0, NULL);
AP_BRIGADE_INSERT_TAIL(bb, e);
if (cachefp && apr_write(cachefp, buffer, &cntr) != APR_SUCCESS) {
@@ -525,6 +533,8 @@
break;
}
ap_pass_brigade(r->output_filters, bb);
+ ap_brigade_destroy(bb);
+ bb = ap_brigade_create(r->pool);
}
}
1.30 +1 -2 apache-2.0/src/modules/proxy/proxy_util.c
Index: proxy_util.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/proxy/proxy_util.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- proxy_util.c 2000/11/17 17:26:32 1.29
+++ proxy_util.c 2000/11/18 03:17:21 1.30
@@ -417,7 +417,7 @@
* the connection closes (EOF), or we timeout.
*/
while ((len = ap_getline(buffer, size, rr, 1)) > 0) {
-
+
if (!(value = strchr(buffer, ':'))) { /* Find the colon separator */
/* Buggy MS IIS servers sometimes return invalid headers
@@ -1108,7 +1108,6 @@
apr_status_t ap_proxy_doconnect(apr_socket_t *sock, char *host, apr_uint32_t port, request_rec *r)
{
apr_status_t rv;
- int i;
apr_sockaddr_t *destsa;
rv = apr_getaddrinfo(&destsa, host, AF_INET, port, 0, r->pool);