|
|
| version 1.24, 2003/07/24 11:31:20 | 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-2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| static const char* IDENT_RESPONSE_C="$Date$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vresponse.h" | #include "pa_vresponse.h" |
| #include "pa_vfile.h" | |
| volatile const char * IDENT_RESPONSE_C="$Id$"; | |
| // class | // class |
| Line 24 public: // Methoded | Line 25 public: // Methoded |
| // global variable | // global variable |
| DECLARE_CLASS_VAR(response, new MResponse, 0); | DECLARE_CLASS_VAR(response, new MResponse); |
| // methods | // methods |
| Line 32 static void _clear(Request& r, MethodPar | Line 33 static void _clear(Request& r, MethodPar |
| GET_SELF(r, VResponse).fields().clear(); | 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<VFile*>(&part)) | |
| params.as_string(0, "part must be string or file"); | |
| r.stream(part); | |
| } | |
| // constructor | // constructor |
| MResponse::MResponse(): Methoded("response") { | MResponse::MResponse(): Methoded("response") { |
| // ^clear[] | // ^clear[] |
| 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); | |
| } | } |