|
|
| version 1.128, 2023/09/26 20:49:11 | version 1.136, 2026/04/25 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: IIS extension. | Parser: IIS extension. |
| Copyright (c) 2000-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2000-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| Line 56 const int IIS51var_count=sizeof(IIS51var | Line 56 const int IIS51var_count=sizeof(IIS51var |
| // globals | // globals |
| char argv0[MAX_STRING]=""; | char argv0[MAX_STRING]=""; |
| const char* parser3_mode="isapi"; // $status:mode | |
| const char *parser3_log_filespec(){ return ""; } // $status:log-filename | |
| // SAPI | // SAPI |
| Line 99 void SAPI::die(const char* fmt, ...) { | Line 101 void SAPI::die(const char* fmt, ...) { |
| // va_end(args); | // va_end(args); |
| } | } |
| void SAPI::send_error(SAPI_Info& SAPI_info, const char *exception_cstr, const char *status){ | |
| // capitalized headers passed for preventing malloc during capitalization | |
| add_header_attribute(SAPI_info, HTTP_STATUS_CAPITALIZED, status); | |
| add_header_attribute(SAPI_info, HTTP_CONTENT_TYPE_CAPITALIZED, "text/plain"); | |
| send_headers(SAPI_info); | |
| send_body(SAPI_info, exception_cstr, strlen(exception_cstr)); | |
| } | |
| char* SAPI::Env::get(SAPI_Info& SAPI_info, const char* name) { | char* SAPI::Env::get(SAPI_Info& SAPI_info, const char* name) { |
| char *variable_buf=new(PointerFreeGC) char[MAX_STRING]; | char *variable_buf=new(PointerFreeGC) char[MAX_STRING]; |
| DWORD variable_len = MAX_STRING-1; | DWORD variable_len = MAX_STRING-1; |
| Line 206 void SAPI::add_header_attribute(SAPI_Inf | Line 216 void SAPI::add_header_attribute(SAPI_Inf |
| } | } |
| /// @todo intelligent cache-control | /// @todo intelligent cache-control |
| void SAPI::send_header(SAPI_Info& SAPI_info) { | void SAPI::send_headers(SAPI_Info& SAPI_info) { |
| HSE_SEND_HEADER_EX_INFO header_info; | HSE_SEND_HEADER_EX_INFO header_info; |
| char status_buf[MAX_STATUS_LENGTH]; | char status_buf[MAX_STATUS_LENGTH]; |
| Line 238 void SAPI::send_header(SAPI_Info& SAPI_i | Line 248 void SAPI::send_header(SAPI_Info& SAPI_i |
| HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); | HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); |
| } | } |
| void SAPI::clear_headers(SAPI_Info& SAPI_info) { | |
| SAPI_info.header=new String; | |
| } | |
| size_t SAPI::send_body(SAPI_Info& SAPI_info, const void *buf, size_t size) { | size_t SAPI::send_body(SAPI_Info& SAPI_info, const void *buf, size_t size) { |
| DWORD num_bytes=size; | DWORD num_bytes=size; |
| if(!SAPI_info.lpECB->WriteClient(SAPI_info.lpECB->ConnID, | if(!SAPI_info.lpECB->WriteClient(SAPI_info.lpECB->ConnID, |
| Line 395 DWORD WINAPI HttpExtensionProc(LPEXTENSI | Line 409 DWORD WINAPI HttpExtensionProc(LPEXTENSI |
| #endif | #endif |
| SAPI_info, header_only); | SAPI_info, header_only); |
| // successful finish | // successful finish |
| } catch(const Exception& e) { // exception in unhandled exception | } catch(const Exception& e) { // just in case |
| // log it | // log it |
| SAPI::log(SAPI_info, "%s", e.comment()); | SAPI::log(SAPI_info, "%s", e.comment()); |
| HSE_SEND_HEADER_EX_INFO header_info; | HSE_SEND_HEADER_EX_INFO header_info; |
| header_info.pszStatus="200 OK"; | header_info.pszStatus="500 Internal Server Error"; |
| header_info.cchStatus=strlen(header_info.pszStatus); | header_info.cchStatus=strlen(header_info.pszStatus); |
| header_info.pszHeader=HTTP_CONTENT_TYPE_CAPITALIZED ": text/plain\r\n\r\n"; | header_info.pszHeader=HTTP_CONTENT_TYPE_CAPITALIZED ": text/plain\r\n\r\n"; |
| header_info.cchHeader=strlen(header_info.pszHeader); | header_info.cchHeader=strlen(header_info.pszHeader); |
| header_info.fKeepConn=true; | header_info.fKeepConn=true; |
| // send header | // send header |
| lpECB->dwHttpStatusCode=200; | lpECB->dwHttpStatusCode=500; |
| lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); | lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); |
| // send body | // send body |