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_NOTIFICA开发者_如何学PythonTION;
}
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?
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".
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
.
精彩评论