int NsAdpProc(void *arg, Ns_Conn *conn) { Ns_Time *ttlPtr = arg; Ns_DString file; int status; Ns_DStringInit(&file); Ns_UrlToFile(&file, Ns_ConnServer(conn), conn->request->url); status = Ns_AdpRequestEx(conn, file.string, ttlPtr); Ns_DStringFree(&file); return status; }
static void php_ns_request_ctor(void) { char *server; Ns_DString ds; char *root; int index; char *tmp; server = Ns_ConnServer(NSG(conn)); #define safe_strdup(x) ((x)?strdup((x)):NULL) SG(request_info).query_string = safe_strdup(NSG(conn->request->query)); Ns_DStringInit(&ds); Ns_UrlToFile(&ds, server, NSG(conn->request->url)); /* path_translated is the absolute path to the file */ SG(request_info).path_translated = safe_strdup(Ns_DStringValue(&ds)); Ns_DStringFree(&ds); root = Ns_PageRoot(server); SG(request_info).request_uri = strdup(SG(request_info).path_translated + strlen(root)); SG(request_info).request_method = NSG(conn)->request->method; if(NSG(conn)->request->version > 1.0) SG(request_info).proto_num = 1001; else SG(request_info).proto_num = 1000; SG(request_info).content_length = Ns_ConnContentLength(NSG(conn)); index = Ns_SetIFind(NSG(conn)->headers, "content-type"); SG(request_info).content_type = index == -1 ? NULL : Ns_SetValue(NSG(conn)->headers, index); SG(sapi_headers).http_response_code = 200; tmp = Ns_ConnAuthUser(NSG(conn)); if (tmp) tmp = estrdup(tmp); SG(request_info).auth_user = tmp; tmp = Ns_ConnAuthPasswd(NSG(conn)); if (tmp) tmp = estrdup(tmp); SG(request_info).auth_password = tmp; NSG(data_avail) = SG(request_info).content_length; }