|
|
| version 1.71, 2002/05/07 07:39:19 | version 1.73, 2002/06/11 14:14:16 |
|---|---|
| Line 50 const char **RCSIds[]={ | Line 50 const char **RCSIds[]={ |
| 0 | 0 |
| }; | }; |
| const char *IIS51vars[]={ | |
| "APPL_MD_PATH", "APPL_PHYSICAL_PATH", | |
| "AUTH_PASSWORD", "AUTH_TYPE", "AUTH_USER", | |
| "CERT_COOKIE", "CERT_FLAGS", "CERT_ISSUER", "CERT_KEYSIZE", "CERT_SECRETKEYSIZE", | |
| "CERT_SERIALNUMBER", "CERT_SERVER_ISSUER", "CERT_SERVER_SUBJECT", "CERT_SUBJECT", | |
| "CONTENT_LENGTH", "CONTENT_TYPE", | |
| "LOGON_USER", | |
| "HTTPS", "HTTPS_KEYSIZE", "HTTPS_SECRETKEYSIZE", "HTTPS_SERVER_ISSUER", "HTTPS_SERVER_SUBJECT", | |
| "INSTANCE_ID", "INSTANCE_META_PATH", | |
| "PATH_INFO", "PATH_TRANSLATED", | |
| "QUERY_STRING", | |
| "REMOTE_ADDR", "REMOTE_HOST", "REMOTE_USER", "REQUEST_METHOD", | |
| "SCRIPT_NAME", | |
| "SERVER_NAME", "SERVER_PORT", "SERVER_PORT_SECURE", "SERVER_PROTOCOL", "SERVER_SOFTWARE", | |
| "URL", | |
| }; | |
| const int IIS51var_count=sizeof(IIS51vars)/sizeof(*IIS51vars); | |
| // globals | // globals |
| char argv0[MAX_STRING]=""; | char argv0[MAX_STRING]=""; |
| Line 104 const char *SAPI::get_env(Pool& pool, co | Line 122 const char *SAPI::get_env(Pool& pool, co |
| if(ctx.lpECB->GetServerVariable(ctx.lpECB->ConnID, const_cast<char *>(name), | if(ctx.lpECB->GetServerVariable(ctx.lpECB->ConnID, const_cast<char *>(name), |
| variable_buf, &variable_len)) { | variable_buf, &variable_len)) { |
| variable_buf[variable_len]=0; | if(*variable_buf) { // saw returning len=1 && *buf=0 :( |
| return variable_buf; | variable_buf[variable_len]=0; |
| return variable_buf; | |
| } | |
| } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { | } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { |
| variable_buf=(char *)pool.malloc(variable_len+1); | variable_buf=(char *)pool.malloc(variable_len+1); |
| if(ctx.lpECB->GetServerVariable(ctx.lpECB->ConnID, const_cast<char *>(name), | if(ctx.lpECB->GetServerVariable(ctx.lpECB->ConnID, const_cast<char *>(name), |
| variable_buf, &variable_len)) { | variable_buf, &variable_len)) { |
| variable_buf[variable_len]=0; | if(*variable_buf) { |
| return variable_buf; | variable_buf[variable_len]=0; |
| return variable_buf; | |
| } | |
| } | } |
| } | } |
| return 0; | return 0; |
| } | } |
| static int grep_char(const char *s, char c) { | |
| int result=0; | |
| if(s) { | |
| while(s=strchr(s, c)) { | |
| s++; // skip found c | |
| result++; | |
| } | |
| } | |
| return result; | |
| } | |
| static const char *mk_env_pair(Pool& pool, const char *key, const char *value) { | |
| char *result=(char *)pool.malloc(strlen(key)+1/*=*/+strlen(value)+1/*0*/); | |
| strcpy(result, key); strcat(result, "="); strcat(result, value); | |
| return result; | |
| } | |
| const char *const *SAPI::environment(Pool& pool) { | |
| // we know this buf is writable | |
| char *all_http_vars=const_cast<char *>(SAPI::get_env(pool, "ALL_HTTP")); | |
| const int http_var_count=grep_char(all_http_vars, '\n')+1/*\n for theoretical(never saw) this \0*/; | |
| const char **result= | |
| (const char **)pool.malloc(sizeof(char *)*(IIS51var_count+http_var_count+1/*0*/)); | |
| const char **cur=result; | |
| // IIS5.1 vars | |
| for(int i=0; i<IIS51var_count; i++) { | |
| const char *key=IIS51vars[i]; | |
| if(const char *value=SAPI::get_env(pool, key)) | |
| *cur++=mk_env_pair(pool, key, value); | |
| } | |
| // HTTP_* vars | |
| if(char *s=all_http_vars) { | |
| while(char *key=lsplit(&s, '\n')) | |
| if(char *value=lsplit(key, ':')) | |
| *cur++=mk_env_pair(pool, key, value); | |
| } | |
| // mark EOE | |
| *cur=0; | |
| return result; | |
| } | |
| size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) { | size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) { |
| SAPI_func_context& ctx=*static_cast<SAPI_func_context *>(pool.get_context()); | SAPI_func_context& ctx=*static_cast<SAPI_func_context *>(pool.get_context()); |
| Line 310 void real_parser_handler(Pool& pool, LPE | Line 376 void real_parser_handler(Pool& pool, LPE |
| request_info.content_type=lpECB->lpszContentType; | request_info.content_type=lpECB->lpszContentType; |
| request_info.content_length=lpECB->cbTotalBytes; | request_info.content_length=lpECB->cbTotalBytes; |
| request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); | request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); |
| request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); | |
| // prepare to process request | // prepare to process request |