]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Server/include/plaqui/server/httpresponse.h
Se agrega un poco mas de documentacion como para cerrar el manual de desarrollo.
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / httpresponse.h
1 // vim: set noexpandtab tabstop=4 shiftwidth=4:
2 //----------------------------------------------------------------------------
3 //                                  PlaQui
4 //----------------------------------------------------------------------------
5 // This file is part of PlaQui.
6 //
7 // PlaQui is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the Free Software
9 // Foundation; either version 2 of the License, or (at your option) any later
10 // version.
11 //
12 // PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 // details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple
19 // Place, Suite 330, Boston, MA  02111-1307  USA
20 //----------------------------------------------------------------------------
21 // Creado:  dom oct 26 18:54:17 ART 2003
22 // Autores: Leandro Lucarella <llucare@fi.uba.ar>
23 //----------------------------------------------------------------------------
24 //
25 // $Id$
26 //
27
28 #ifndef PLAQUI_HTTPRESPONSE_H
29 #define PLAQUI_HTTPRESPONSE_H
30
31 #include "plaqui/server/httperror.h"
32 #include "plaqui/server/httpmessage.h"
33 #include <socket++/sockstream.h>
34 #include <string>
35
36 namespace PlaQui {
37
38 namespace Server {
39
40         /// Respuesta HTTP.
41         class HTTPResponse: public HTTPMessage {
42
43                 /////////////////////////////////////////////////////////////////////
44                 // Tipos.
45
46                 public:
47
48                         typedef enum {
49                                 INVALID_HTTP_RESPONSE,
50                                 INVALID_HTTP_VERSION,
51                                 INVALID_HTTP_RESPONSE_CODE,
52                                 MISSING_HTTP_RESPONSE_CODE
53                         } Error;
54
55                 /////////////////////////////////////////////////////////////////////
56                 // Atributos.
57
58                 //protected: FIXME - hacer privado con get/set?
59                 public:
60
61                         /// Código de estado.
62                         unsigned status_code;
63
64                         /// Descripción del código (razón).
65                         std::string reason;
66
67                 /////////////////////////////////////////////////////////////////////
68                 // Métodos.
69
70                 public:
71
72                         /**
73                          * Destructor.
74                          */
75                         virtual ~HTTPResponse(void);
76
77                         /**
78                          * Constructor.
79                          */
80                         HTTPResponse(const std::string& body = "",
81                                         const std::string& version = "1.1");
82
83                         /**
84                          * Constructor.
85                          */
86                         HTTPResponse(const HTTPError& error);
87
88                         /**
89                          * Constructor.
90                          */
91                         HTTPResponse(unsigned status_code, const std::string& body = "");
92
93                         /**
94                          * Constructor.
95                          */
96                         //HTTPResponse(unsigned status_code, const std::string& reason,
97                         //              const std::string& body,
98                         //              const std::string& version = "1.1");
99
100                         /**
101                          * Obtiene los datos de la respuesta HTTP desde un texto.
102                          */
103                         friend std::istream& operator>>(std::istream& is,
104                                         HTTPResponse& resp)
105                                 throw(Error, sockerr, std::ios::failure);
106
107                         /**
108                          * Convierte la respuesta HTTP en texto.
109                          */
110                         friend std::ostream& operator<<(std::ostream& os,
111                                         const HTTPResponse& resp) throw(sockerr);
112
113         };
114
115 }
116
117 }
118
119 #endif // PLAQUI_HTTPRESPONSE_H