|
|
| version 1.12, 2001/06/28 07:41:59 | version 1.38, 2026/10/14 23:18:32 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b response parser class. | Parser: @b response parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | |
| $Id$ | |
| */ | */ |
| static char *RCSId="$Id$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_request.h" | #include "pa_vmethod_frame.h" |
| // defines | #include "pa_request.h" |
| #include "pa_vresponse.h" | |
| #include "pa_vfile.h" | |
| #define RESPONSE_CLASS_NAME "response" | volatile const char * IDENT_RESPONSE_C="$Id$"; |
| // class | // class |
| class MResponse : public Methoded { | class MResponse: public Methoded { |
| public: | public: |
| MResponse(Pool& pool); | MResponse(); |
| public: // Methoded | public: // Methoded |
| bool used_directly() { return false; } | bool used_directly() { return false; } |
| }; | }; |
| // methods | // global variable |
| static void _clear(Request& r, const String&, MethodParams *) { | DECLARE_CLASS_VAR(response, new MResponse); |
| r.self/*VResponse*/->get_hash()/*sure not 0*/->clear(); | |
| } | |
| // constructor | // methods |
| MResponse::MResponse(Pool& apool) : Methoded(apool) { | |
| set_name(*NEW String(pool(), RESPONSE_CLASS_NAME)); | |
| static void _clear(Request& r, MethodParams&) { | |
| GET_SELF(r, VResponse).fields().clear(); | |
| } | |
| // ^clear[] | static void _stream(Request& r, MethodParams& params) { |
| add_native_method("clear", Method::CT_DYNAMIC, _clear, 0, 0); | Value& part=params[0]; |
| // checked here, before headers are sent | |
| if(!dynamic_cast<VFile*>(&part)) | |
| params.as_string(0, "part must be string or file"); | |
| r.stream(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) { | // ^stream[string or file]: the headers go with the first part, the result of @main is not sent then |
| return response_class=new(pool) MResponse(pool); | add_native_method("stream", Method::CT_STATIC, _stream, 1, 1); |
| } | } |