At BNA we have a problem with use of AOLserver in terms of how it handles the Location parameter value. The Location is a fixed value that is a "global constant" for the AOLserver process.
In our virtual hosting environment on our production machines this a problem. The problem is as follows: The machine host name is >>> xyz.bna.com One of many virtual host names is >>> productA.bna.com User requests >>> http://productA.bna.com/AAAA (notice that there is no / at the end of the user request) According to spec AOLserver should redirect to the complete url. Wanted behavior is a redirect to >>> http://productA.bna.com/AAAA/ actual behavior is a redirect to >>> http://xyz.bna.com/AAAA/ Our location is the machine name because we can only set one. But one location is not sufficient for our needs. I am aware of the many different Virtual Hosting solutions that are proposed for AOLserver. But we found a way to fix our problem without actually needing to use any of the currently specified Virtual Hosting approaches. I would like to get your opinion on our approach to solving our problem. In nsd/return.c we have modified the function Ns_ConnReturnRedirect. Please note the additional block of code marked with a "ZZZ BNA" comment. What this does is return the user specified host name in preference to the Location value. This solves our particular problem. It is not a Virtual Hosting solution per se, but it does solve our problem. My question is: Do any of you who know the code better than we do think this is a dangerous thing to do? If so where should I look in the code to see the danger? Our testing has shown no problems with this change, at least not so far! Here is the modified source code: Ns_ConnReturnRedirect(Ns_Conn *conn, char *url) { Ns_DString ds, msg; int result; char* host; Ns_DStringInit(&ds); Ns_DStringInit(&msg); if (url != NULL) { if (*url == '/') { /* ZZZ BNA - we look for a host entry before defaulting to the location value. */ host = Ns_SetGet(conn->headers, "Host"); if (host) { Ns_DStringAppend(&ds, "http://"); Ns_DStringAppend(&ds, host); } else { Ns_DStringAppend(&ds, Ns_ConnLocation(conn)); } } Ns_DStringAppend(&ds, url); Ns_HeadersPut(conn, "Location", ds.string); Ns_DStringVarAppend(&msg, "<A HREF=\"", ds.string, "\">The requested URL has moved here.</A>", NULL); result = Ns_ReturnNotice(conn, 302, "Redirection", msg.string); } else { result = Ns_ReturnNotice(conn, 204, "No Content", msg.string); } Ns_DStringFree(&msg); Ns_DStringFree(&ds); return result; } Thanks for the help! /pgw Greg Wolff [EMAIL PROTECTED]
