--- parser3/src/classes/response.C 2001/04/15 13:12:18 1.7 +++ parser3/src/classes/response.C 2026/10/14 23:18:32 1.38 @@ -1,29 +1,52 @@ /** @file Parser: @b response parser class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: response.C,v 1.7 2001/04/15 13:12:18 paf Exp $ + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ +#include "classes.h" +#include "pa_vmethod_frame.h" + #include "pa_request.h" -#include "_response.h" +#include "pa_vresponse.h" +#include "pa_vfile.h" + +volatile const char * IDENT_RESPONSE_C="$Id: response.C,v 1.38 2026/10/14 23:18:32 moko Exp $"; + +// class -// global var +class MResponse: public Methoded { +public: + MResponse(); +public: // Methoded + bool used_directly() { return false; } +}; -VStateless_class *response_class; +// global variable + +DECLARE_CLASS_VAR(response, new MResponse); // methods -static void _clear(Request& r, const String&, MethodParams *) { - r.self/*VResponse*/->get_hash()/*sure not 0*/->clear(); +static void _clear(Request& r, MethodParams&) { + GET_SELF(r, VResponse).fields().clear(); +} + +static void _stream(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.stream(part); } -// initialize +// constructor -void initialize_response_class(Pool& pool, VStateless_class& vclass) { +MResponse::MResponse(): Methoded("response") { // ^clear[] - vclass.add_native_method("clear", Method::CT_DYNAMIC, _clear, 0, 0); + add_native_method("clear", Method::CT_STATIC, _clear, 0, 0); + + // ^stream[string or file]: the headers go with the first part, the result of @main is not sent then + add_native_method("stream", Method::CT_STATIC, _stream, 1, 1); }