--- parser3/src/classes/response.C 2001/03/18 11:37:46 1.1 +++ parser3/src/classes/response.C 2026/10/10 12:58:07 1.37 @@ -1,21 +1,52 @@ -/* - Parser - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) +/** @file + Parser: @b response parser class. - $Id: response.C,v 1.1 2001/03/18 11:37:46 paf Exp $ + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ -#include "_response.h" +#include "classes.h" +#include "pa_vmethod_frame.h" -// global var +#include "pa_request.h" +#include "pa_vresponse.h" +#include "pa_vfile.h" -VStateless_class *response_base_class; +volatile const char * IDENT_RESPONSE_C="$Id: response.C,v 1.37 2026/10/10 12:58:07 moko Exp $"; + +// class + +class MResponse: public Methoded { +public: + MResponse(); +public: // Methoded + bool used_directly() { return false; } +}; + +// global variable + +DECLARE_CLASS_VAR(response, new MResponse); // methods -// initialize +static void _clear(Request& r, MethodParams&) { + GET_SELF(r, VResponse).fields().clear(); +} + +static void _send(Request& r, MethodParams& params) { + Value& part=params[0]; + // checked here, before headers are sent + if(!dynamic_cast(&part)) + params.as_string(0, "part must be string or file"); + r.send(part); +} + +// constructor + +MResponse::MResponse(): Methoded("response") { + // ^clear[] + add_native_method("clear", Method::CT_STATIC, _clear, 0, 0); -void initialize_response_base_class(Pool& pool, VStateless_class& vclass) { - // TODO: ^mangle + // ^send[string or file]: the headers go with the first part, the result of @main is not sent then + add_native_method("send", Method::CT_STATIC, _send, 1, 1); }