--------------------- PatchSet 2391 Date: 2001/05/28 12:16:47 Author: adri Branch: newhttp Tag: (none) Log: Initial http errorpage filter. This doesn't do very much - I haven't figured out how the filters are actually used stlil. Members: configure.in:1.1.1.3.8.11.2.8.2.2->1.1.1.3.8.11.2.8.2.3 src/modules/http_error/Makefile.in:1.1->1.1.2.1 src/modules/http_error/http_error.c:1.1->1.1.2.1 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.1.1.3.8.11.2.8.2.2 retrieving revision 1.1.1.3.8.11.2.8.2.3 diff -u -r1.1.1.3.8.11.2.8.2.2 -r1.1.1.3.8.11.2.8.2.3 --- squid/configure.in 13 May 2001 13:07:07 -0000 1.1.1.3.8.11.2.8.2.2 +++ squid/configure.in 28 May 2001 12:16:47 -0000 1.1.1.3.8.11.2.8.2.3 @@ -3,13 +3,13 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.1.1.3.8.11.2.8.2.2 2001/05/13 13:07:07 rbcollins Exp $ +dnl $Id: configure.in,v 1.1.1.3.8.11.2.8.2.3 2001/05/28 12:16:47 adri Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.1.1.3.8.11.2.8.2.2 $)dnl +AC_REVISION($Revision: 1.1.1.3.8.11.2.8.2.3 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(cfgaux) @@ -899,7 +899,7 @@ esac ]) if test -z "$CONF_MODULES"; then - CONF_MODULES="http_upstream http_client" + CONF_MODULES="http_upstream http_client http_error" fi if test -n "$CONF_MODULES"; then echo "Generic modules built: $CONF_MODULES" --- /dev/null Wed Feb 14 00:52:54 2007 +++ squid/src/modules/http_error/Makefile.in Wed Feb 14 00:53:29 2007 @@ -0,0 +1,70 @@ +# +# Makefile for the http error handling +# +# $Id: Makefile.in,v 1.1.2.1 2001/05/28 12:16:47 adri Exp $ +# + +MODULE = http_error + +#SUBDIRS = helpers + +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +MAKEDEPEND = @MAKEDEPEND@ +AR_R = @AR_R@ +RANLIB = @RANLIB@ +AC_CFLAGS = @CFLAGS@ +SHELL = /bin/sh + +INCLUDE = -I../../../include -I$(top_srcdir)/include -I$(top_srcdir)/src/ +CFLAGS = $(AC_CFLAGS) $(INCLUDE) $(DEFINES) + +OUT = ../$(MODULE).a + +OBJS = \ + http_error.o + + +all install: $(OUT) + @for dir in $(SUBDIRS); do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) $@" || exit 1; \ + fi; \ + done; + +$(OUT): $(OBJS) + @rm -f ../stamp + $(AR_R) $(OUT) $(OBJS) + $(RANLIB) $(OUT) + +$(OBJS): $(top_srcdir)/include/version.h ../../../include/autoconf.h + +.c.o: + @rm -f ../stamp + $(CC) $(CFLAGS) -c $< + +clean: + -rm -rf *.o *pure_* core ../$(MODULE).a + -for dir in *; do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) clean"; \ + fi; \ + done + +distclean: clean + -rm -f Makefile + -rm -f Makefile.bak + -rm -f tags + -for dir in *; do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) distclean"; \ + fi; \ + done + +tags: + ctags *.[ch] $(top_srcdir)/src/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[ch] + +depend: + $(MAKEDEPEND) $(INCLUDE) -fMakefile *.c --- /dev/null Wed Feb 14 00:52:54 2007 +++ squid/src/modules/http_error/http_error.c Wed Feb 14 00:53:29 2007 @@ -0,0 +1,163 @@ + +/* + * $Id: http_error.c,v 1.1.2.1 2001/05/28 12:16:47 adri Exp $ + * + * DEBUG: section 83 HTTP errorpage module + * AUTHOR: Adrian Chadd + * + * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from the + * Internet community. Development is led by Duane Wessels of the + * National Laboratory for Applied Network Research and funded by the + * National Science Foundation. Squid is Copyrighted (C) 1998 by + * the Regents of the University of California. Please see the + * COPYRIGHT file for full details. Squid incorporates software + * developed and/or copyrighted by other sources. Please see the + * CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +/* + * http error page handling module - this filter is used when + * a HTTP error page needs to be returned to a client. + */ + +#include "squid.h" + +typedef struct _http_error_state http_error_state; +struct _http_error_state +{ + char *url; + /* Which error */ + + /* Our error page buffer */ + MemBuf page_content; + +}; + +static REMOVEFILTER http_error_Remove; +static ADDFILTER http_error_Add; +static FILTERMKSTATE http_error_MakeState; +#if 0 +static FILTERPARSE http_error_Parse; +#endif +static DATAFILTER http_error; + +static void +http_error_AddInstance (FILTER_instance * instance) +{ + instance->Add = http_error_Add; + instance->MakeState = http_error_MakeState; +#if 0 + instance->Parse = http_error_Parse; +#endif + instance->data = NULL; + /* Set defaults, if sensible defaults exist */ + /* lock the instance */ + cbdataLock(instance); +} + +static void +http_error_RemInstance (FILTER_instance * instance) +{ + instance->Add = NULL; + instance->MakeState = NULL; + instance->data = NULL; + cbdataUnlock(instance); +} + +static void +http_error_Add (dlink_list * filters, void *filter_config) +{ + filterChainAddTail(filters, http_error, http_error, http_error_Remove,filter_config); +#if 0 + FILTER_list *temp_filter; + temp_filter = xmalloc (sizeof (FILTER_list)); + temp_filter->filter = http_error; + temp_filter->Remove = http_error_Remove; + temp_filter->data = filter_config; + /* cbDataLock(http); ? */ + dlinkAddTail (temp_filter, &temp_filter->node, filters); +#endif +} + +static void * +http_error_MakeState (void *data, clientHttpRequest * http, HttpReply *rep, request_t *request) +{ + http_error_state *state; + /* it's up to the filter writer wether to refcount the config, + * or copy it. For now, to save learning cbdata, I copy it + */ + state = xmalloc (sizeof (http_error_state)); + if (request && request->canonical) + state->url=xstrdup(request->canonical); + else if (http && http->uri) + state->url=xstrdup(http->uri); + else + state->url=xstrdup("No urlpath"); + return state; +} + +static void +http_error_Remove (FILTER_list * filters, dlink_list * filter_list, + void *data) +{ + http_error_state *state = data; + dlinkDelete (&filters->node, filter_list); + xfree (filters); + safe_free(state->url); + xfree (state); +} + +#if 0 +static void +http_error_Parse (void *data, const char *namestr, char *param_str) +{ + debug (33, 0) ("unrecognised parameter '%s' for filter %s\n", param_str, + namestr); +} +#endif + +/* register as a module */ +void +mod_install_http_error (const char *namestr) +{ + /* Register as a potential client_side reply filter */ + filterRegisterModule (namestr, http_error_AddInstance, + http_error_RemInstance); +} + +/* deregister as a module */ +void +mod_uninstall_http_error(const char *namestr) +{ + filterDeregisterModule(namestr); +} + +DATAFILTER_FILTER(http_error_filter) +{ + http_error_state *state=data; + FILTER_list *temp_filter=filters->node.next->data; + + fatal("Time to do error stuff!\n"); + + debug(1,1)("**** Spying my dummy filter (buf=%x,len=%d,offset=%d,flags=%d url=%s\n",buf,len,offset,flags,state->url); + return temp_filter->filter(buf,len, offset,filter_list,temp_filter,flags,temp_filter->data); +} +