tags:

views:

176

answers:

2

I have an ISAPI filter that I am using to do URL rewriting for my CMS. I am processing SF_NOTIFY_PREPROC_HEADERS notifications, and trying to do this:

DWORD ProcessHeader(HTTP_FILTER_CONTEXT *con, HTTP_FILTER_PREPROC_HEADERS *head)
{
    head->SetHeader(con, "test1", "aaa");
    con->AddResponseHeaders(con, "test2:bbb\r\n", 0);
    return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

However, I can't seem to read these values using server variables or response headers in classic ASP or PHP. The values are missing. I'm expecting either my "test1" or "test2" header values to appear, but they are not. Am I doing something wrong here?

+1  A: 

Seems to be correct. But both methods return a BOOL. Check them and call GetLastError() if they return FALSE.
EDIT:
I'm not quite sure but you may also try out to return SF_STATUS_REQ_FINISHED instead of SF_STATUS_REQ_NEXT_NOTIFICATION.

Simon Linder
I can't believe I forgot that. :( The SetHeader call is returning error 87. I'll dig into that further.
Jon Tackabury
A: 

I finally figured it out, I was missing a ':' in the header name:

DWORD ProcessHeader(HTTP_FILTER_CONTEXT *con, HTTP_FILTER_PREPROC_HEADERS *head)
{
    head->SetHeader(con, "test1:", "aaa");
    return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

This now creates a server variable called "HTTP_TEST1".

Jon Tackabury