--- parser3/src/include/pa_sapi.h 2015/10/26 01:21:56 1.31 +++ parser3/src/include/pa_sapi.h 2024/11/10 00:28:42 1.41 @@ -1,20 +1,20 @@ /** @file Parser: web server api interface object decl. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_SAPI_H #define PA_SAPI_H -#define IDENT_PA_SAPI_H "$Id: pa_sapi.h,v 1.31 2015/10/26 01:21:56 moko Exp $" +#define IDENT_PA_SAPI_H "$Id: pa_sapi.h,v 1.41 2024/11/10 00:28:42 moko Exp $" // includes - -#include "pa_types.h" +#include "pa_common.h" #include "pa_array.h" +#include "pa_exception.h" // forwards class SAPI_Info; @@ -25,16 +25,18 @@ struct SAPI { static void log(SAPI_Info& info, const char* fmt, ...); /// log error message & exit static void die(const char* fmt, ...); - /// log error message & abort[write core] - static void abort(const char* fmt, ...); /// read POST request bytes static size_t read_post(SAPI_Info& info, char *buf, size_t max_bytes); /// add response header attribute [but do not send it to client] static void add_header_attribute(SAPI_Info& info, const char* dont_store_key, const char* dont_store_value); /// send collected header attributes to client - static void send_header(SAPI_Info& info); + static void send_headers(SAPI_Info& info); + /// clear collected header attributes + static void clear_headers(SAPI_Info& info); /// output body bytes static size_t send_body(SAPI_Info& info, const void *buf, size_t size); + // send error to client + static void send_error(SAPI_Info& info, const char *exception_cstr, const char *status = "500"); class Env { public: @@ -42,6 +44,7 @@ struct SAPI { static const char* const* get(SAPI_Info& ainfo); /// single environment string static char* get(SAPI_Info& ainfo, const char* name); + static bool set(SAPI_Info& ainfo, const char* name, const char* value); class Iterator { private: @@ -49,7 +52,7 @@ struct SAPI { const char* pair; const char* eq_at; public: - Iterator(SAPI_Info& asapi_info) { + Iterator(SAPI_Info& asapi_info) : pair(NULL), eq_at(NULL){ if(pairs=SAPI::Env::get(asapi_info)) next(); }