On Tuesday 05 September 2006 12:42, Daniel P. Stasinski wrote: > On 9/5/06, Tom Jackson <[EMAIL PROTECTED]> wrote: > > I spent several hours fixing a bug with internal redirects, then found > > out it had already been fixed. > > If a status had been mapped to a url, then the server redirects > > (internally) to that url. > > Can you elaborate more on this? I'm having a similar problem right > now with 4.5. > > I have a registered adp as: > > ns_register_adp GET /checkout [ns_info pageroot]/rewrites/checkout.adp > > and when I do a ns_returnredirect "http://blahblah.com/checkout" from > another ADP, I get a segfault. I can redirect to any other site, just > not the same site.
Internal redirects are those which don't send a response back to the client, the code justs changes the target url and runs the 'page' which is at that location. I haven't noticed (or looked for) any problems with ns_returnredirect. However, the bug I found was due to an API using a page level global var, not sure exactly what you call this in C, but the API was on another page. The two files involved were server.c (defined var) and return.c (tried to use it). The result was the var was NULL, so the registering procedure didn't do anything. You could have a similar problem. tom jackson Here is what I changed: return.c: void Ns_RegisterReturn2(NsServer *servPtr, int status, char *url) { Tcl_HashEntry *hPtr; int new; if (servPtr != NULL) { hPtr = Tcl_CreateHashEntry(&servPtr->request.redirect, (char *) status, &new); if (!new) { ns_free(Tcl_GetHashValue(hPtr)); } if (url == NULL) { Tcl_DeleteHashEntry(hPtr); Ns_Log(Error, "return: redirect not registered status = '%i' url = '%s'", status, url); } else { Tcl_SetHashValue(hPtr, ns_strdup(url)); Ns_Log(Notice, "return: redirect registered status = '%i' url = '%s'", status, url); } } else { Ns_Log(Error, "return: redirect server not found"); } } in server.c: /* * Configure the url, proxy and redirect requests. */ Tcl_InitHashTable(&servPtr->request.proxy, TCL_STRING_KEYS); Ns_MutexInit(&servPtr->request.plock); Ns_MutexSetName2(&servPtr->request.plock, "nsd:proxy", server); path = Ns_ConfigGetPath(server, NULL, "redirects", NULL); set = Ns_ConfigGetSection(path); Tcl_InitHashTable(&servPtr->request.redirect, TCL_ONE_WORD_KEYS); for (i = 0; set != NULL && i < Ns_SetSize(set); ++i) { key = Ns_SetKey(set, i); map = Ns_SetValue(set, i); status = atoi(key); if (status <= 0 || *map == '\0') { Ns_Log(Error, "return: invalid redirect '%s=%s'", key, map); } else { Ns_Log(Notice, "return: redirect mapped '%s=%s'", key, map); <-- added this Ns_RegisterReturn2(servPtr, status, map); <--- changed this } } /* * Initialize ADP. */ -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.