virtual DWORD OnUrlMap( CHttpFilterContext* pfc, PHTTP_FILTER_URL_MAP pUrlMap );
Return Value
One of the following notification types:
SF_STATUS_REQ_FINISHED
The filter has handled the HTTP request. The server should disconnect the session.
SF_STATUS_REQ_FINISHED_KEEP_CONN
Same as SF_STATUS_REQ_FINISHED except the server should keep the TCP session open if the option was negotiated.
SF_STATUS_REQ_NEXT_NOTIFICATION
The next filter in the notification chain should be called.
SF_STATUS_REQ_HANDLED_NOTIFICATION
This filter handled the notification. No other handlers should be called for this particular notification.
SF_STATUS_REQ_ERROR
An error occurred. The server should use the Win32 API SetLastError to indicate the error to the client.
SF_STATUS_REQ_READ_NEXT
The filter is an opaque stream filter; Negotiate the session parameters. Only valid for raw read notification.
If unsuccessful, the notification type SF_STATUS_REQ_ERROR should be returned. In this case, the server should use the Windows function SetLastError and indicate the error to the client.
Parameters
pfc
A CHttpFilterContext object, which contains context information. The CHttpFilterContext object can be used by the filter to associate any context information with the HTTP request.
pUrlMap
A pointer to an HTTP_FILTER_URL_MAP structure.
Remarks
This member function is called by the framework when the server is mapping a logical URL to a physical path.
Override this member function handle URL mapping differently. The default implementation does nothing.
Example
The following code demonstrates how to use an OnUrlMap notification in the filter to redirect a request to a different URL. If the URL contains a DoRedirect string (for example, http://server/doRedirect), the request will be redirected to http://www.microsoft.com.
DWORD CFiltRedirFilter::OnUrlMap(CHttpFilterContext* pCtxt,
PHTTP_FILTER_URL_MAP pMapInfo)
{
CHAR szRedirect [256];
if (strstr (pMapInfo->pszURL, "DoRedirect"))
{
CHAR szRedirect [256];
// replace www.microsoft.com with desired server
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "www.microsoft.com");
pCtxt->ServerSupportFunction ( SF_REQ_SEND_RESPONSE_HEADER,
(LPVOID) "302 Redirect",
(DWORD *) szRedirect,
0 );
// Print a message to the debug window
ISAPITRACE1 ("Redirecting to: %s\n", szRedirect);
// we are done with this request
return SF_STATUS_REQ_FINISHED_KEEP_CONN;
}
// URL did not contain a DoRedirect string.
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
CHttpFilter Overview | Class Members | Hierarchy Chart
See Also CHttpFilter::HttpFilterProc, HTTP_FILTER_URL_MAP, CHttpFilterContext