*** proxy_http.c.orig	Wed Jun 19 08:55:52 2002
--- proxy_http.c	Wed Jun 19 08:45:01 2002
***************
*** 170,175 ****
--- 170,178 ----
      const char *datestr, *urlstr;
      int result, major, minor;
      const char *content_length;
+ #ifdef EAPI
+     char *peer;
+ #endif
  
      void *sconf = r->server->module_config;
      proxy_server_conf *conf =
***************
*** 191,196 ****
--- 194,205 ----
          return HTTP_BAD_REQUEST;
      urlptr += 3;
      destport = DEFAULT_HTTP_PORT;
+ #ifdef EAPI
+     ap_hook_use("ap::mod_proxy::http::handler::set_destport", 
+                 AP_HOOK_SIG2(int,ptr), 
+                 AP_HOOK_TOPMOST,
+                 &destport, r);
+ #endif /* EAPI */
      strp = strchr(urlptr, '/');
      if (strp == NULL) {
          desthost = ap_pstrdup(p, urlptr);
***************
*** 228,233 ****
--- 237,245 ----
          err = ap_proxy_host2addr(proxyhost, &server_hp);
          if (err != NULL)
              return DECLINED;    /* try another */
+ #ifdef EAPI
+ 	peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);  
+ #endif
      }
      else {
          server.sin_port = htons((unsigned short)destport);
***************
*** 234,239 ****
--- 246,254 ----
          err = ap_proxy_host2addr(desthost, &server_hp);
          if (err != NULL)
              return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
+ #ifdef EAPI
+ 	peer =  ap_psprintf(p, "%s:%u", desthost, destport);  
+ #endif
      }
  
  
***************
*** 308,321 ****
--- 323,365 ----
      f = ap_bcreate(p, B_RDWR | B_SOCKET);
      ap_bpushfd(f, sock, sock);
  
+ #ifdef EAPI
+     {
+         char *errmsg = NULL;
+         ap_hook_use("ap::mod_proxy::http::handler::new_connection",
+                     AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
+                     AP_HOOK_DECLINE(NULL),
+                     &errmsg, r, f, peer);
+         if (errmsg != NULL)
+             return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
+     }
+ #endif /* EAPI */
+ 
      ap_hard_timeout("proxy send", r);
      ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
                NULL);
+ 
+ #ifdef EAPI
+     {
+       int rc = DECLINED;
+       ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
+                   AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
+                   AP_HOOK_DECLINE(DECLINED),
+                   &rc, r, f, desthost, destport, destportstr);
+         if (rc == DECLINED) {
+           if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
+               ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
+           else
+               ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
+        }
+     }
+ #else /* EAPI */
      /* Send Host: now, adding it to req_hdrs wouldn't be much better */
      if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
          ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
      else
          ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
+ #endif /* EAPI */
  
      if (conf->viaopt == via_block) {
          /* Block all outgoing Via: headers */
