try to connect before remove header handler to return a compliant 500 error to browse...
[mod-proxy-fdpass.git] / mod_proxy_fdpass.c
index 0e2ba33..9dbd0a9 100644 (file)
@@ -343,23 +343,9 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
     apr_size_t wrlen;
     const char *post_data = NULL;
 
-    if ((headers_out = calloc(CTRL_BUFF_MAX_SZ, 1)) != NULL) {
-        sprintf(headers_out, "The-Request:%s\n", r->the_request);
-        apr_table_do(headers_builder, headers_out, r->headers_in, NULL);
-    }
-    read_post(r, &post_data);
+    ap_filter_t *f;
+    ap_filter_rec_t *fg;
 
-    {
-        int mop_fd;
-        char mop_bf[512];
-
-        mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
-        sprintf(mop_bf, "proxy_fdpass_handler: start\n");
-        write(mop_fd, mop_bf, strlen(mop_bf));
-        write(mop_fd, headers_out, strlen(headers_out));
-        close(mop_fd);
-
-    }
     if (strncasecmp(url, "fd://", 5) == 0) {
         url += 5;
     }
@@ -376,6 +362,41 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
+    fg = ap_get_output_filter_handle("HTTP_HEADER");
+
+
+    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                  "proxy: FD: filter fg: %lx  func %lx", fg, ap_http_header_filter);
+
+
+    for (f = r->output_filters ; f != NULL ; f = f->next) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                      "proxy: FD: filter loop: %lx", f->frec);
+        if (f->frec == fg) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "proxy: FD: filter found, remove it");
+            ap_remove_output_filter(f);
+            break;
+        }
+    }
+
+    if ((headers_out = calloc(CTRL_BUFF_MAX_SZ, 1)) != NULL) {
+        sprintf(headers_out, "The-Request:%s\n", r->the_request);
+        apr_table_do(headers_builder, headers_out, r->headers_in, NULL);
+    }
+    read_post(r, &post_data);
+
+    {
+        int mop_fd;
+        char mop_bf[512];
+
+        mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
+        sprintf(mop_bf, "proxy_fdpass_handler: start\n");
+        write(mop_fd, mop_bf, strlen(mop_bf));
+        write(mop_fd, headers_out, strlen(headers_out));
+        close(mop_fd);
+
+    }
     /* create a couple of sockets and pass one to the client for headers and so on */
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, ctrlrawsock)) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
@@ -481,8 +502,7 @@ static int standard_flush(request_rec *r)
 
     r->connection->keepalive = AP_CONN_CLOSE;
     /* MOP NOTE: set here the content type */
-    // ap_set_content_type(r, apr_pstrdup(p, "text/plain"));
-
+    // ap_set_content_type(r, apr_pstrdup(p, NO_CONTENT_TYPE));
     bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
     e = apr_bucket_flush_create(r->connection->bucket_alloc);