--- parser3/src/targets/cgi/pa_sapi_info.h 2020/12/16 14:51:26 1.13 +++ parser3/src/targets/cgi/pa_sapi_info.h 2024/07/14 16:54:18 1.16 @@ -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.13 2020/12/16 14:51:26 moko Exp $" +#define IDENT_PA_SAPI_INFO_H "$Id: pa_sapi_info.h,v 1.16 2024/07/14 16:54:18 moko Exp $" #include "pa_sapi.h" #include "pa_http.h" @@ -95,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) {} @@ -122,13 +122,18 @@ public: env.put("QUERY_STRING", connection.query()); env.put("SERVER_NAME", host); + env.put("SERVER_PORT", HTTPD_Server::port); env.put("REMOTE_ADDR", connection.remote_addr); } virtual char* get_env(const char* name) { - String::Body value = env.get(name); - return !value ? NULL : value.cstrm(); + String::Body request_value = env.get(name); + if(!request_value.is_empty()) + return request_value.cstrm(); + if(char *server_value=getenv(name)) + return pa_strdup(server_value); + return NULL; } virtual bool set_env(const char* name, const char* value) { @@ -161,6 +166,11 @@ 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;