]> granicus.if.org Git - apache/commitdiff
More proxy fixes. There are still some bugs in this code, but this has
authorRyan Bloom <rbb@apache.org>
Sat, 18 Nov 2000 03:17:21 +0000 (03:17 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 18 Nov 2000 03:17:21 +0000 (03:17 +0000)
successfully proxied www.yahoo.com and www.ntrnet.net among other test
sites that I chose at random.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87001 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/proxy_http.c
modules/proxy/proxy_util.c

index 96652ea092b950449df397df83b4bd5b398f0c19..2420b6f4d4089234460093fd0136b8ad1ff1d72a 100644 (file)
@@ -361,7 +361,7 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
     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 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
     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 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
        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 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
 
        buffer2[12] = '\0';
        r->status = atoi(&buffer2[9]);
+
        buffer2[12] = ' ';
        r->status_line = apr_pstrdup(p, &buffer2[9]);
 
@@ -421,6 +425,9 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
         {
             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 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
 #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,18 +495,19 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
            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);
@@ -525,6 +533,8 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
                 break;
             }
             ap_pass_brigade(r->output_filters, bb);
+            ap_brigade_destroy(bb);
+            bb = ap_brigade_create(r->pool);
         }
     }
 
index 8c97004b5634a59bbfaf0b21cccbcfc26c7f147d..a2e0263cc94976cd98a518203c91c631657ca2b6 100644 (file)
@@ -417,7 +417,7 @@ apr_table_t *ap_proxy_read_headers(request_rec *r, char *buffer, int size, conn_
      * 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 @@ static int proxy_match_word(struct dirconn_entry *This, request_rec *r)
 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);