--- parser3/src/targets/cgi/pa_sapi_info.h 2020/12/09 12:37:06 1.11 +++ parser3/src/targets/cgi/pa_sapi_info.h 2020/12/17 11:47:17 1.14 @@ -1,7 +1,7 @@ #ifndef PA_SAPI_INFO_H #define PA_SAPI_INFO_H -#define IDENT_PA_SAPI_INFO_H "$Id: pa_sapi_info.h,v 1.11 2020/12/09 12:37:06 moko Exp $" +#define IDENT_PA_SAPI_INFO_H "$Id: pa_sapi_info.h,v 1.14 2020/12/17 11:47:17 moko Exp $" #include "pa_sapi.h" #include "pa_http.h" @@ -9,6 +9,10 @@ /// IIS refuses to read bigger chunks const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M +// for signal handlers and cgi console detection +static Request *request=0; + + class SAPI_Info : public PA_Allocated { public: int http_response_code; @@ -69,7 +73,7 @@ public: virtual void add_header_attribute(const char* dont_store_key, const char* dont_store_value) { SAPI_Info::add_header_attribute(dont_store_key, dont_store_value); -// if(!request || !request->console.was_used()) + if(!request || !request->console.was_used()) printf("%s: %s\n", capitalize(dont_store_key), dont_store_value); } @@ -91,7 +95,7 @@ class SAPI_Info_HTTPD : public SAPI_Info public: HTTPD_Connection &connection; - String output; + String::Body output; HashStringString env; SAPI_Info_HTTPD(HTTPD_Connection &aconnection) : connection(aconnection) {} @@ -157,15 +161,22 @@ public: output << capitalize(dont_store_key) << ": " << pa_strdup(dont_store_value) << "\r\n"; } + void clear_response_headers() { + http_response_code=200; + output.clear(); + } + static const char *exception_http_status(const char *type) { struct Lookup { const char *code; const char *type; } static lookup[] = { + { "", "httpd.write"}, {"400", "httpd.request"}, {"400", "http.response"}, {"404", "file.missing"}, {"408", "httpd.timeout"}, + {"408", "httpd.read"}, {"501", "httpd.method"}, { NULL, ""} };