httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@hyperreal.com>
Subject cvs commit: apache/src mod_actions.c
Date Tue, 09 Apr 1996 03:59:54 GMT
akosut      96/04/08 20:59:53

  Modified:    src       mod_actions.c
  Log:
  Add Script command, which allows you to define a script to handle
  requests for methods that Apache cannot (GET w/ args, POST, PUT and
  DELETE). Based on the CERN Search, POST-Script, PUT-Script and
  DELETE-Script directives.
  
  Revision  Changes    Path
  1.3       +60 -11    apache/src/mod_actions.c
  
  Index: mod_actions.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_actions.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -C3 -r1.2 -r1.3
  *** mod_actions.c	1996/03/31 01:07:00	1.2
  --- mod_actions.c	1996/04/09 03:59:51	1.3
  ***************
  *** 78,83 ****
  --- 78,87 ----
    
    typedef struct {
        table *action_types;	/* Added with Action... */
  +     char *get;			/* Added with Script GET */
  +     char *post;			/* Added with Script POST */
  +     char *put;			/* Added with Script PUT */
  +     char *delete;		/* Added with Script DELETE */
    } 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;
    }
    
  ***************
  *** 111,119 ****
  --- 124,151 ----
        return NULL;
    }
    
  + char *set_script (cmd_parms *cmd, action_dir_config *m, char *method,
  + 		  char *script)
  + {
  +     if (!strcmp(method, "GET"))
  +         m->get = pstrdup(cmd->pool, script);
  +     else if (!strcmp(method, "POST"))
  +         m->post = pstrdup(cmd->pool, script);
  +     else if (!strcmp(method, "PUT"))
  +         m->put = pstrdup(cmd->pool, script);
  +     else if (!strcmp(method, "DELETE"))
  +         m->delete = pstrdup(cmd->pool, script);
  +     else
  +         return "Unknown method type for Script";
  + 
  +     return NULL;
  + }
  + 
    command_rec action_cmds[] = {
    { "Action", add_action, NULL, OR_FILEINFO, TAKE2, 
        "a media type followed by a script name" },
  + { "Script", set_script, NULL, ACCESS_CONF|RSRC_CONF, TAKE2,
  +     "a method followed by a script name" },
    { 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;
    }
    
  --- 153,189 ----
    {
        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;
    }
    
  
  
  

Mime
View raw message