#ifndef DBMS_OWA_H #define DBMS_OWA_H #include #include #include #ifdef __cplusplus extern "C" { #endif #include "postgres.h" #include "fmgr.h" #include "datatype/timestamp.h" Datum owa_init_cgi_env(PG_FUNCTION_ARGS); Datum owa_init_cgi_env2(PG_FUNCTION_ARGS); Datum owa_cookie_send(PG_FUNCTION_ARGS); Datum owa_cookie_send2(PG_FUNCTION_ARGS); Datum owa_cache_disable(PG_FUNCTION_ARGS); Datum owa_cache_set_cache(PG_FUNCTION_ARGS); Datum owa_cache_set_expires(PG_FUNCTION_ARGS); Datum owa_cache_set_not_modified(PG_FUNCTION_ARGS); Datum owa_cache_set_surrogate_control(PG_FUNCTION_ARGS); Datum owa_cache_set_request_etag(PG_FUNCTION_ARGS); Datum owa_cache_set_request_level(PG_FUNCTION_ARGS); Datum owa_cache_get_etag(PG_FUNCTION_ARGS); Datum owa_cache_get_etag2(PG_FUNCTION_ARGS); Datum owa_cache_get_level(PG_FUNCTION_ARGS); Datum owa_util_get_cgi_env(PG_FUNCTION_ARGS); Datum owa_util_showpage(PG_FUNCTION_ARGS); Datum owa_util_showpage_utils(PG_FUNCTION_ARGS); #ifdef __cplusplus } /* extern "C" */ namespace Owa { enum class EventKind { BodyText, Cookie, Cache, Status }; enum class PageState { HeadersOpen, BodyStarted }; struct CookieData { std::string name; std::string value; bool has_expires = false; TimestampTz expires = 0; bool has_path = false; std::string path; bool has_domain = false; std::string domain; bool has_secure = false; }; struct EventEntry { EventKind kind; SubTransactionId subxid; std::string bodyText; CookieData cookieData; std::string cacheEtag; std::string cacheLevel; int32 cacheExpires = 0; bool cacheDisabled = false; std::string cacheSurrogateControl; int32 statusCode = 0; std::string statusReason; }; struct PageContext { std::vector events; PageState state = PageState::HeadersOpen; bool hasRequestCacheEtag = false; std::string requestCacheEtag; bool hasRequestCacheLevel = false; std::string requestCacheLevel; bool hasRequestProtocol = false; std::string requestProtocol; std::unordered_map cgiValues; }; extern PageContext *current_page_context_; extern bool xact_callback_registered_; extern bool subxact_callback_registered_; std::string textToString(text *value); void validateHeaderValue(const std::string &arg_value, const char *arg_name); void validateCookieName(const std::string &cookie_name); void validateCacheEtag(const std::string &etag_value); std::string validateAndNormalizeCacheLevel(const std::string &level_value); std::string renderCacheHeaders(const std::string &etag_value, const std::string &level_value); void validateCacheExpires(int32 expires_value); std::string renderExpiresHeaders(int32 expires_value, const std::string &level_value); void validateSurrogateControlValue(const std::string &value); void ensureCallbackRegistered(void); void ensurePageContextViaServiceInit(void); void resetPageContext(void); void appendHtpText(const char *text, bool add_new_line); std::string normalizeCgiName(const std::string &cgi_name); } #endif #endif /* DBMS_OWA_H */