Server variables provide information about the HTTP server environment. Frequently an ISAPI filter will need to determine the value of a server variable before it can process event information. The following code would return the value of the SERVER_PORT_SECURE server variable.
DWORD WINAPI HttpFilterProc( PHTTP_FILTER_CONTEXT pfc, DWORD NotificationType, LPVOID pvNotification ) { HTTP_FILTER_PREPROC_HEADERS *pHeaders = pvNotification; char szServerName[1024], szUrl[1024], szSecure[2], szLocationHeader[1034], szRequest[1024]; DWORD dwBuffSize; dwBuffSize = 1024; pfc->GetServerVariable(pfc, "URL", szRequest, &dwBuffSize); // Determine if request was sent over secure port dwBuffSize = 2; pfc->GetServerVariable(pfc, "SERVER_PORT_SECURE", szSecure, &dwBuffSize); if (szSecure[0] == '1') // Request is on a secure port, do not process further return SF_STATUS_REQ_NEXT_NOTIFICATION; dwBuffSize = 1024; pfc->GetServerVariable(pfc, "SERVER_NAME", szServerName, &dwBuffSize); // pfc->GetServerVariable(pfc, "HTTP_HOST", szServerName, &dwBuffSize); dwBuffSize = 1024; pHeaders->GetHeader(pfc, "url", szUrl, &dwBuffSize); wsprintf(szLocationHeader, "Location: https://%s%s\r\n\r\n", szServerName, szUrl); pfc->AddResponseHeaders(pfc, szLocationHeader, 0); pfc->ServerSupportFunction(pfc, SF_REQ_SEND_RESPONSE_HEADER, "302 Object Moved", (DWORD)"Please resubmit the request using a secure port.", 0); return SF_STATUS_REQ_FINISHED; }