httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@nueva.pvt.k12.ca.us>
Subject Re: PUT /foo.html HTTP/1.0
Date Mon, 08 Apr 1996 08:38:58 GMT
On Sun, 7 Apr 1996, Robert S. Thau wrote:

> Actually, Alexei, putting the PUT-script functionality into Apache
> should be a fairly simple take-off on your own mod-actions.c code;
> probably pretty simple and worthwhile.  (I don't think we know
> enough about the right policies to adopt to think about wiring them
> into the server yet, and PUT isn't a high-volume thing anyway).

Hmm. Okay. Good point, mod_actions does have most of the needed
structures already. Here's a patch that puts it into mod_actions
instead of mod_cgi, as did my last patch. Most of the code is actually
the same, but I'd still like some feedback on it before (if) I commit
it:

Index: mod_actions.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_actions.c,v
retrieving revision 1.2
diff -c -r1.2 mod_actions.c
*** mod_actions.c	1996/03/31 01:07:00	1.2
--- mod_actions.c	1996/04/08 08:37:43
***************
*** 78,83 ****
--- 78,87 ----

  typedef struct {
      table *action_types;	/* Added with Action... */
+     char *get;			/* Added with Search */
+     char *post;			/* Added with POST-Script */
+     char *put;			/* Added with PUT-Script */
+     char *delete;		/* Added with DELETE-Script */
  } action_dir_config;

  module action_module;
***************
*** 88,93 ****
--- 92,101 ----
        (action_dir_config *) palloc (p, sizeof(action_dir_config));

      new->action_types = make_table (p, 4);
+     new->get = NULL;
+     new->post = NULL;
+     new->put = NULL;
+     new->delete = NULL;

      return new;
  }
***************
*** 102,107 ****
--- 110,120 ----
      new->action_types = overlay_tables (p, add->action_types,
  					  base->action_types);

+     new->get = add->get ? add->get : base->get;
+     new->post = add->post ? add->post : base->post;
+     new->put = add->put ? add->put : base->put;
+     new->delete = add->delete ? add->delete : base->delete;
+
      return new;
  }

***************
*** 114,119 ****
--- 127,140 ----
  command_rec action_cmds[] = {
  { "Action", add_action, NULL, OR_FILEINFO, TAKE2,
      "a media type followed by a script name" },
+ { "Search", set_string_slot, (void*)XtOffsetOf(action_dir_config, get),
+     ACCESS_CONF|RSRC_CONF, TAKE1, "a CGI script to handle GET searches" },
+ { "POST-Script", set_string_slot, (void*)XtOffsetOf(action_dir_config, post),
+     ACCESS_CONF|RSRC_CONF, TAKE1, "a CGI script to handle POST requests" },
+ { "PUT-Script", set_string_slot, (void*)XtOffsetOf(action_dir_config, put),
+     ACCESS_CONF|RSRC_CONF, TAKE1, "a CGI script to handle PUT requests" },
+ { "DELETE-Script",set_string_slot,(void*)XtOffsetOf(action_dir_config, delete),
+     ACCESS_CONF|RSRC_CONF, TAKE1, "a CGI script to handle DELETE requests" },
  { NULL }
  };

***************
*** 121,140 ****
  {
      action_dir_config *conf =
        (action_dir_config *)get_module_config(r->per_dir_config,&action_module);
!     char *action = r->handler ? r->handler : r->content_type;
!     char *t;

!     if (!action ||
! 	!(t = table_get(conf->action_types, action)))
!       return DECLINED;
!
!     if (r->finfo.st_mode == 0) {
!       log_reason("File does not exist", r->filename, r);
!       return NOT_FOUND;
      }

!     internal_redirect_handler(pstrcat(r->pool, t, escape_uri(r->pool, r->uri),
! 				      r->args ? "?" : NULL, r->args, NULL), r);
      return OK;
  }

--- 142,178 ----
  {
      action_dir_config *conf =
        (action_dir_config *)get_module_config(r->per_dir_config,&action_module);
!     char *t, *action = r->handler ? r->handler : r->content_type;
!     char *script = NULL;

!     /* First, check for the method-handling scripts */
!     if ((r->method_number == M_GET) && r->args && conf->get)
!         script = conf->get;
!     else if ((r->method_number == M_POST) && conf->post)
!         script = conf->post;
!     else if ((r->method_number == M_PUT) && conf->put)
!         script = conf->put;
!     else if ((r->method_number == M_DELETE) && conf->delete)
!         script = conf->delete;
!
!     /* Check for looping, which can happen if the CGI script isn't */
!     if (script && r->prev && r->prev->prev)
!         return DECLINED;
!
!     /* Second, check for actions (which override the method scripts) */
!     if (action && (t = table_get(conf->action_types, action))) {
!         script = t;
! 	if (r->finfo.st_mode == 0) {
! 	    log_reason("File does not exist", r->filename, r);
! 	    return NOT_FOUND;
! 	}
      }
+
+     if (script == NULL)
+         return DECLINED;

!     internal_redirect_handler(pstrcat(r->pool, script, escape_uri(r->pool,
! 			r->uri), r->args ? "?" : NULL, r->args, NULL), r);
      return OK;
  }



--
________________________________________________________________________
Alexei Kosut <akosut@nueva.pvt.k12.ca.us>
URL: http://www.nueva.pvt.k12.ca.us/~akosut/
Lefler on IRC, DALnet <http://www.dal.net/>


Mime
View raw message