The R Project SVN R

Rev

Rev 65805 | Rev 68899 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65805 Rev 68392
Line 537... Line 537...
537
	    fn[c - e] = 0;
537
	    fn[c - e] = 0;
538
	    DBG(Rprintf("handler_for_path('%s'): looking up custom handler '%s'\n", path, fn));
538
	    DBG(Rprintf("handler_for_path('%s'): looking up custom handler '%s'\n", path, fn));
539
	    /* we cache custom_handlers_env so in case it has not been loaded yet, fetch it */
539
	    /* we cache custom_handlers_env so in case it has not been loaded yet, fetch it */
540
	    if (!custom_handlers_env) {
540
	    if (!custom_handlers_env) {
541
		if (!R_HandlersName) R_HandlersName = install(".httpd.handlers.env");
541
		if (!R_HandlersName) R_HandlersName = install(".httpd.handlers.env");
-
 
542
		SEXP toolsNS = PROTECT(R_FindNamespace(mkString("tools")));
542
		custom_handlers_env = eval(R_HandlersName, R_FindNamespace(mkString("tools")));
543
		custom_handlers_env = eval(R_HandlersName, toolsNS);
-
 
544
		UNPROTECT(1); /* toolsNS */
543
	    }
545
	    }
544
	    /* we only proceed if .httpd.handlers.env really exists */
546
	    /* we only proceed if .httpd.handlers.env really exists */
545
	    if (TYPEOF(custom_handlers_env) == ENVSXP) {
547
	    if (TYPEOF(custom_handlers_env) == ENVSXP) {
546
		SEXP cl = findVarInFrame3(custom_handlers_env, install(fn), TRUE);
548
		SEXP cl = findVarInFrame3(custom_handlers_env, install(fn), TRUE);
547
		if (cl != R_UnboundValue && TYPEOF(cl) == CLOSXP) /* we need a closure */
549
		if (cl != R_UnboundValue && TYPEOF(cl) == CLOSXP) /* we need a closure */
Line 582... Line 584...
582
				  sTrue));
584
				  sTrue));
583
	SET_TAG(CDR(CDR(x)), install("silent"));
585
	SET_TAG(CDR(CDR(x)), install("silent"));
584
	DBG(Rprintf("eval(try(httpd('%s'),silent=TRUE))\n", c->url));
586
	DBG(Rprintf("eval(try(httpd('%s'),silent=TRUE))\n", c->url));
585
	
587
	
586
	/* evaluate the above in the tools namespace */
588
	/* evaluate the above in the tools namespace */
587
	x = PROTECT(eval(x, R_FindNamespace(mkString("tools"))));
589
	SEXP toolsNS = PROTECT(R_FindNamespace(mkString("tools")));
-
 
590
	x = eval(x, toolsNS);
-
 
591
	UNPROTECT(1); /* toolsNS */
-
 
592
	PROTECT(x);
588
 
593
 
589
	/* the result is expected to have one of the following forms:
594
	/* the result is expected to have one of the following forms:
590
 
595
 
591
	   a) character vector of length 1 => error (possibly from try),
596
	   a) character vector of length 1 => error (possibly from try),
592
	      will create 500 response
597
	      will create 500 response