--- parser3/src/classes/response.C 2002/08/01 11:41:13 1.21 +++ parser3/src/classes/response.C 2026/10/10 12:58:07 1.37 @@ -1,42 +1,52 @@ /** @file Parser: @b response parser class. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ -static const char* IDENT_RESPONSE_C="$Date: 2002/08/01 11:41:13 $"; - #include "classes.h" +#include "pa_vmethod_frame.h" + #include "pa_request.h" +#include "pa_vresponse.h" +#include "pa_vfile.h" + +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 { +class MResponse: public Methoded { public: - MResponse(Pool& pool); + MResponse(); public: // Methoded bool used_directly() { return false; } }; +// global variable + +DECLARE_CLASS_VAR(response, new MResponse); + // methods -static void _clear(Request& r, const String& method_name, MethodParams *) { - r.self/*VResponse*/->get_hash(&method_name)/*sure not 0*/->clear(); +static void _clear(Request& r, MethodParams&) { + GET_SELF(r, VResponse).fields().clear(); } -// constructor - -MResponse::MResponse(Pool& apool) : Methoded(apool, "response") { - // ^clear[] - add_native_method("clear", Method::CT_DYNAMIC, _clear, 0, 0); +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); } -// global variable -Methoded *response_class; +// constructor -// creator +MResponse::MResponse(): Methoded("response") { + // ^clear[] + add_native_method("clear", Method::CT_STATIC, _clear, 0, 0); -Methoded *MResponse_create(Pool& pool) { - return response_class=new(pool) MResponse(pool); + // ^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); }