You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modproxy-dev@apache.org by Ian Holsman <Ia...@cnet.com> on 2001/05/16 17:28:01 UTC
[PATCH] Reverse Proxy HTTP Hooks
hi.
I know you guys were working on a 'filter' method of doing this,
but I needed a method quickly so I got this hook method working.
the main reason me doing this via a hook instead of a filter, is that
I couldn't see an 'easy' way to tell apache to set filters on a Reverse
Proxy call.
..Ian
Index: proxy_http.c
===================================================================
RCS file: /home/cvspublic/httpd-proxy/module-2.0/proxy_http.c,v
retrieving revision 1.70
diff -u -b -r1.70 proxy_http.c
--- proxy_http.c 2001/05/11 17:32:37 1.70
+++ proxy_http.c 2001/05/16 15:29:04
@@ -59,6 +59,7 @@
/* HTTP routines for Apache proxy */
#include "mod_proxy.h"
+#include "proxy_http.h"
module AP_MODULE_DECLARE_DATA proxy_http_module;
@@ -483,7 +483,7 @@
e = apr_bucket_pool_create(buf, strlen(buf), p);
APR_BRIGADE_INSERT_TAIL(bb, e);
}
-
+proxy_http_run_pre_request( r );
/* handle Via */
if (conf->viaopt == via_block) {
/* Block all outgoing Via: headers */
@@ -613,7 +613,7 @@
*/
rp = make_fake_req(origin, r);
-
+proxy_http_run_post_request( r );
apr_brigade_cleanup(bb);
if (APR_SUCCESS != (rv = ap_proxy_string_read(origin, bb, buffer, sizeof(buffer), &eos))) {
@@ -833,3 +833,18 @@
NULL, /* command apr_table_t */
ap_proxy_http_register_hook /* register hooks */
};
+
+
+APR_HOOK_STRUCT(
+ APR_HOOK_LINK(pre_request)
+ APR_HOOK_LINK(post_request)
+)
+
+APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy_http, PROXY_HTTP, int, pre_request,
+ (request_rec *r),(r),DECLINED)
+APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy_http, PROXY_HTTP, int, post_request,
+ (request_rec *r),(r),DECLINED)
+
-- proxy_http.h
#ifndef _PROXY_HTTP_H
#define _PROXY_HTTP_H 1
#if !defined(WIN32)
#define PROXY_HTTP_DECLARE(type) type
#define PROXY_HTTP_DECLARE_NONSTD(type) type
#define PROXY_HTTP_DECLARE_DATA
#elif defined(PROXY__HTTP_DECLARE_STATIC)
#define PROXY_HTTP_DECLARE(type) type __stdcall
#define PROXY_HTTP_DECLARE_NONSTD(type) type
#define PROXY_HTTP_DECLARE_DATA
#elif defined(PROXY_HTTP_DECLARE_EXPORT)
#define PROXY_HTTP_DECLARE(type) __declspec(dllexport) type __stdcall
#define PROXY_HTTP_DECLARE_NONSTD(type) __declspec(dllexport) type
#define PROXY_HTTP_DECLARE_DATA __declspec(dllexport)
#else
#define PROXY_HTTP_DECLARE(type) __declspec(dllimport) type __stdcall
#define PROXY_HTTP_DECLARE_NONSTD(type) __declspec(dllimport) type
#define PROXY_HTTP_DECLARE_DATA __declspec(dllimport)
#endif
/*
typedef int proxy_http_HOOK_pre_request_t (request_rec *r);
PROXY_HTTP_DECLARE(void) proxy_http_hook_pre_request(proxy_http_HOOK_pre_request_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder); PROXY_HTTP_DECLARE(int) proxy_http_run_pre_request (request_rec *r); PROXY_HTTP_DECLARE(apr_array_header_t *) proxy_http_hook_get_pre_request(void); typedef struct proxy_http_LINK_pre_request_t { proxy_http_HOOK_pre_request_t *pFunc; const char *szName; const char * const *aszPredecessors; const char * const *aszSuccessors; int nOrder; } proxy_http_LINK_pre_request_t;
typedef int proxy_http_HOOK_post_request_t (request_rec *r); PROXY_HTTP_DECLARE(void) proxy_http_hook_post_request(proxy_http_HOOK_post_request_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder); PROXY_HTTP_DECLARE(int) proxy_http_run_post_request (request_rec *r); PROXY_HTTP_DECLARE(apr_array_header_t *) proxy_http_hook_get_post_request(void); typedef struct proxy_http_LINK_post_request_t { proxy_http_HOOK_post_request_t *pFunc; const char *szName; const char * const *aszPredecessors; const char * const *aszSuccessors; int nOrder; } proxy_http_LINK_post_request_t;
*/
APR_DECLARE_EXTERNAL_HOOK(proxy_http, PROXY_HTTP, int, pre_request,
(request_rec *r))
APR_DECLARE_EXTERNAL_HOOK(proxy_http, PROXY_HTTP, int, post_request,
(request_rec *r))
#endif /* PROXY_HTTP */
--
Ian Holsman
Performance Measurement & Analysis
415-364-8608
Re: [PATCH] Reverse Proxy HTTP Hooks
Posted by Graham Leggett <mi...@sharp.fm>.
Ian Holsman wrote:
> I know you guys were working on a 'filter' method of doing this,
> but I needed a method quickly so I got this hook method working.
>
> the main reason me doing this via a hook instead of a filter, is that
> I couldn't see an 'easy' way to tell apache to set filters on a Reverse
> Proxy call.
What does this code do?
Regards,
Graham
--
-----------------------------------------
minfrin@sharp.fm "There's a moon
over Bourbon Street
tonight..."