Annotation of parser3/src/classes/response.C, revision 1.38

1.6       paf         1: /** @file
                      2:        Parser: @b response parser class.
                      3: 
1.36      moko        4:        Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.34      moko        5:        Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.20      paf         6: */
1.6       paf         7: 
1.10      paf         8: #include "classes.h"
1.24      paf         9: #include "pa_vmethod_frame.h"
                     10: 
1.3       paf        11: #include "pa_request.h"
1.24      paf        12: #include "pa_vresponse.h"
1.37      moko       13: #include "pa_vfile.h"
1.1       paf        14: 
1.38    ! moko       15: volatile const char * IDENT_RESPONSE_C="$Id: response.C,v 1.37 2026/10/10 12:58:07 moko Exp $";
1.28      moko       16: 
1.8       paf        17: // class
                     18: 
1.24      paf        19: class MResponse: public Methoded {
1.8       paf        20: public:
1.24      paf        21:        MResponse();
1.11      paf        22: public: // Methoded
1.8       paf        23:        bool used_directly() { return false; }
                     24: };
1.1       paf        25: 
1.24      paf        26: // global variable
                     27: 
1.30      moko       28: DECLARE_CLASS_VAR(response, new MResponse);
1.24      paf        29: 
1.1       paf        30: // methods
                     31: 
1.24      paf        32: static void _clear(Request& r, MethodParams&) {
                     33:        GET_SELF(r, VResponse).fields().clear();
1.3       paf        34: }
                     35: 
1.38    ! moko       36: static void _stream(Request& r, MethodParams& params) {
1.37      moko       37:        Value& part=params[0];
                     38:        // checked here, before headers are sent
                     39:        if(!dynamic_cast<VFile*>(&part))
                     40:                params.as_string(0, "part must be string or file");
1.38    ! moko       41:        r.stream(part);
1.37      moko       42: }
                     43: 
1.8       paf        44: // constructor
                     45: 
1.24      paf        46: MResponse::MResponse(): Methoded("response") {
1.3       paf        47:        // ^clear[]
1.31      moko       48:        add_native_method("clear", Method::CT_STATIC, _clear, 0, 0);
1.37      moko       49: 
1.38    ! moko       50:        // ^stream[string or file]: the headers go with the first part, the result of @main is not sent then
        !            51:        add_native_method("stream", Method::CT_STATIC, _stream, 1, 1);
1.1       paf        52: }

E-mail: