try to connect before remove header handler to return a compliant 500 error to browse...
[mod-proxy-fdpass.git] / mod_proxy_fdpass.c
index 7a12ba0..9dbd0a9 100644 (file)
@@ -346,6 +346,22 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
     ap_filter_t *f;
     ap_filter_rec_t *fg;
 
+    if (strncasecmp(url, "fd://", 5) == 0) {
+        url += 5;
+    }
+    else {
+        return DECLINED;
+    }
+
+    rv = get_socket_from_path(r, r->pool, url, &sock);
+
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                      "proxy: FD: Failed to connect to '%s' %d xxx",
+                      url, rv);
+        return HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     fg = ap_get_output_filter_handle("HTTP_HEADER");
 
 
@@ -364,12 +380,6 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
         }
     }
 
-#if 0
-    ap_custom_response(r, 0, "sappo: robiola zero");
-    ap_custom_response(r, 200, "sappo: robiola");
-    apr_table_clear(r->headers_out);
-#endif
-
     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);
@@ -387,22 +397,6 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
         close(mop_fd);
 
     }
-    if (strncasecmp(url, "fd://", 5) == 0) {
-        url += 5;
-    }
-    else {
-        return DECLINED;
-    }
-
-    rv = get_socket_from_path(r, r->pool, url, &sock);
-
-    if (rv != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                      "proxy: FD: Failed to connect to '%s' %d xxx",
-                      url, rv);
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
-
     /* 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,
@@ -532,23 +526,9 @@ static const proxy_fdpass_flush builtin_flush =
     NULL
 };
 
-#if 0
-static int proxy_fdpass_post_request(proxy_worker *worker,
-                                       proxy_balancer *balancer,
-                                       request_rec *r,
-                                       proxy_server_conf *conf)
-{
-    apr_table_clear(r->headers_out);
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                  "proxy: FD: POST");
-
-}
-#endif
-
 static void ap_proxy_fdpass_register_hooks(apr_pool_t *p)
 {
     ap_register_provider(p, PROXY_FDPASS_FLUSHER, "flush", "0", &builtin_flush);
-    //    proxy_hook_post_request(proxy_fdpass_post_request, NULL, NULL, APR_HOOK_FIRST);
     proxy_hook_scheme_handler(proxy_fdpass_handler, NULL, NULL, APR_HOOK_FIRST);
     proxy_hook_canon_handler(proxy_fdpass_canon, NULL, NULL, APR_HOOK_FIRST);
 }