--- parser3/src/include/pa_sapi.h 2020/10/14 00:07:42 1.35 +++ parser3/src/include/pa_sapi.h 2024/11/10 00:28:42 1.41 @@ -1,14 +1,14 @@ /** @file Parser: web server api interface object decl. - Copyright (c) 2001-2017 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.35 2020/10/14 00:07:42 moko Exp $" +#define IDENT_PA_SAPI_H "$Id: pa_sapi.h,v 1.41 2024/11/10 00:28:42 moko Exp $" // includes @@ -30,17 +30,13 @@ struct SAPI { /// 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); - - static void send_error(SAPI_Info& info, const char *exception_cstr, const char *status = "500"){ - // capitalized headers passed for preventing malloc during capitalization - add_header_attribute(info, HTTP_STATUS_CAPITALIZED, status); - add_header_attribute(info, HTTP_CONTENT_TYPE_CAPITALIZED, "text/plain"); - send_header(info); - send_body(info, exception_cstr, strlen(exception_cstr)); - } + // send error to client + static void send_error(SAPI_Info& info, const char *exception_cstr, const char *status = "500"); class Env { public: @@ -48,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: