SYNOPSIS
#include "ns.h"
int
Ns_ConnRedirect(conn, url)
ARGUMENTS
-
Ns_Conn conn (in)
Pointer to open connection. -
char *url (in)
Pointer to string of local url.
DESCRIPTION
This routine can be used to internally redirect to a new, local url on the server. The url paramter specifies a path relative to the server, i.e., without the leading "http://host:port" portion. The server will reset the Ns_Request structure in the open connection pointed to by conn and restart connection handling, including authorization checks. The result is a standard AOLserver request procedure result code, either from an underlying call to Ns_ConnRunRequest or the result of one of the authorization response routines such as Ns_ConnReturnForbidden. Filter callbacks, if any, are not run again with the updated connection.
The Ns_ConnRedirect routine is used internally in the server to support the basic file serving code (i.e., "fastpath") to redirect to specific files when a directory is opened and by the Ns_RegisterRedirect routine to map standard reponse routines to user-provided local url's.
EXAMPLE
The following example demonstrates redirecting to an ADP help page within a custom C-level request callback whenever a ?help=topic query argument is present:
-
int MyRequest(void *arg, Ns_Conn *conn) { Ns_Set *query = Ns_ConnGetQuery(conn); /* Redirect to help.adp for /myrequest?help=topic calls. */ if (Ns_SetGet(query, "help")) != NULL) { return Ns_ConnReturnRedirect(conn, "/help.adp"); } ... handle non-help requests ... }
KEYWORDS
connection, redirect