/** * Look at the request to see if Caucho should handle it. */ static int cse_dispatch(request_rec *r) { config_t *config = cse_get_module_config(r); const char *host = ap_get_server_name(r); const char *uri = r->uri; unsigned int now = r->request_time; LOG(("CONF: %p\n", config)); if (config == NULL) return DECLINED; /* cse_update_config(config, r->request_time); */ if (config->enable_caucho_status && strstr(uri, "/caucho-status")) { r->handler = "caucho-status"; return OK; } /* Check for exact virtual host match */ if (cse_match_request(config, host, ap_get_server_port(r), uri, 0, now) || r->handler && ! strcmp(r->handler, "caucho-request")) { r->handler = "caucho-request"; LOG(("[%d] match %s:%s\n", getpid(), host ? host : "null", uri)); return OK; } LOG(("[%d] mismatch %s:%s\n", getpid(), host ? host : "null", uri)); return DECLINED; }
/** * Look at the request to see if Resin should handle it. */ static int cse_dispatch(request_rec *r) { config_t *config = cse_get_module_config(r); const char *host_name = ap_get_server_name(r); int port = ap_get_server_port(r); const char *uri = r->uri; resin_host_t *host; unsigned int now; int len; if (config == NULL || ! uri) return DECLINED; now = time(0); LOG(("%s:%d:cse_dispatch(): [%d] host %s\n", __FILE__, __LINE__, getpid(), host_name ? host_name : "null")); len = strlen(uri); /* move back below host */ if (config->enable_caucho_status && len >= sizeof("/caucho-status") - 1 && ! strcmp(uri + len - sizeof("/caucho-status") + 1, "/caucho-status")) { r->handler = "caucho-status"; return caucho_status(r); } /* Check for exact virtual host match */ host = cse_match_request(config, host_name, port, uri, 0, now); if (host || (r->handler && ! strcmp(r->handler, "caucho-request"))) { LOG(("%s:%d:cse_dispatch(): [%d] match %s:%s\n", __FILE__, __LINE__, getpid(), host_name ? host_name : "null", uri)); return caucho_request(r, config, host, now); } else if (r->handler && ! strcmp(r->handler, "caucho-status")) { return caucho_status(r); } if (config->session_url_prefix) { return cse_strip(r); } return DECLINED; }
DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification) { char url[URL_SIZE]; char host[1024]; char port_buf[80]; int port = 0; unsigned long size; char query = 0; unsigned int query_index = 0; HTTP_FILTER_PREPROC_HEADERS *headers=NULL;; HTTP_FILTER_AUTH_COMPLETE_INFO *AuthComp=NULL;; if (g_is_iis5 < 0) { char version[1024]; size = sizeof(version); g_is_iis5 = 0; if (pfc->GetServerVariable(pfc, "SERVER_SOFTWARE", version, &size)) { LOG(("IIS version %s\n", version)); g_is_iis5 = atof(version + strlen("Microsoft-IIS/")) >= 5.0; } else { LOG(("Can't Get SERVER_SOFTWARE %d\n",GetLastError())); } } switch (notificationType) { case SF_NOTIFY_PREPROC_HEADERS: LOG(("HttpFilterProc: SF_NOTIFY_PREPROC_HEADERS\n")); if (g_is_iis5) break; headers = (HTTP_FILTER_PREPROC_HEADERS *) pvNotification; size = sizeof(host); host[0] = 0; pfc->GetServerVariable(pfc, "SERVER_NAME", host, &size); size = sizeof(port_buf); if (pfc->GetServerVariable(pfc, "SERVER_PORT", port_buf, &size) && size > 0) { port = atoi(port_buf); } size = sizeof(url); if (headers->GetHeader(pfc, "URL", url, &size) && size > 0) { url[size] = 0; for (query_index = 0; query_index < size; query_index++) { if (url[query_index] == '?') { query = url[query_index]; url[query_index] = 0; break; } } DWORD request_time = GetTickCount() / 1000; if (cse_match_request(g_config, host, port, url, 1, request_time) || g_config->enable_caucho_status && ! strcmp(url, "/caucho-status")) { char newurl[SCRIPT_URL_SIZE]; if (! pfc->pFilterContext) { pfc->pFilterContext = pfc->AllocMem(pfc, SCRIPT_URL_SIZE, 0); if (! pfc->pFilterContext) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return SF_STATUS_REQ_ERROR; } ((char *) pfc->pFilterContext)[0] = 0; } url[query_index] = query; strcpy(newurl, ISAPI_SCRIPT); strcat(newurl, url); headers->SetHeader(pfc, "URL", newurl); strcpy((char *) pfc->pFilterContext, url); ((char *) pfc->pFilterContext)[query_index] = 0; } } break; case SF_NOTIFY_AUTH_COMPLETE: LOG(("HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE\n")); AuthComp = (HTTP_FILTER_AUTH_COMPLETE_INFO *) pvNotification; size = sizeof(host); host[0] = 0; pfc->GetServerVariable(pfc, "SERVER_NAME", host, &size); size = sizeof(port_buf); if (pfc->GetServerVariable(pfc, "SERVER_PORT", port_buf, &size) && size > 0) { port = atoi(port_buf); } size = sizeof(url); if (AuthComp->GetHeader(pfc, "URL", url, &size) && size > 0) { url[size] = 0; for (query_index = 0; query_index < size; query_index++) { if (url[query_index] == '?') { query = url[query_index]; url[query_index] = 0; break; } } DWORD request_time = GetTickCount() / 1000; if (cse_match_request(g_config, host, port, url, 1, request_time) || g_config->enable_caucho_status && ! strcmp(url, "/caucho-status")) { char newurl[SCRIPT_URL_SIZE]; if (! pfc->pFilterContext) { pfc->pFilterContext = pfc->AllocMem(pfc, SCRIPT_URL_SIZE, 0); if (! pfc->pFilterContext) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return SF_STATUS_REQ_ERROR; } ((char *) pfc->pFilterContext)[0] = 0; } url[query_index] = query; strcpy(newurl, ISAPI_SCRIPT); strcat(newurl, url); AuthComp->SetHeader(pfc, "URL", newurl); strcpy((char *) pfc->pFilterContext, url); ((char *) pfc->pFilterContext)[query_index] = 0; } } break; case SF_NOTIFY_LOG: LOG(("NOTIFY-LOG %p\n", pfc->pFilterContext)); if (pfc->pFilterContext && ((char *) pfc->pFilterContext)[0]) { char *pch = (char *) pfc->pFilterContext; LOG(("NOTIFY_LOG %s\n", pch ? pch : "null")); HTTP_FILTER_LOG *pLog = (HTTP_FILTER_LOG *) pvNotification; pLog->pszTarget = pch; } break; default: LOG(("Log %d\n", notificationType)); break; } return SF_STATUS_REQ_NEXT_NOTIFICATION; }