]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/include/plaqui/server/httpmessage.h
Se pasa la conexion suicida al finish del TCPServer para que sea 'transparente'.
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / httpmessage.h
index 888eacf1f7b70f0b2ccb0746d8247533b6987312..37c0287764c7771ecdb3aadabdb50f1f67e39174 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef PLAQUI_HTTPMESSAGE_H
 #define PLAQUI_HTTPMESSAGE_H
 
+#include "plaqui/server/httpheaders.h"
 #include <string>
 
 namespace PlaQui {
@@ -37,6 +38,22 @@ namespace Server {
        /// Pedido HTTP.
        class HTTPMessage {
 
+               /////////////////////////////////////////////////////////////////////
+               // Constantes.
+
+               public:
+
+                       /// \todo TODO completar codigos.
+                       static const unsigned OK                         = 200;
+                       static const unsigned BAD_REQUEST                = 401;
+                       static const unsigned NOT_FOUND                  = 404;
+                       static const unsigned CONFLICT                   = 409;
+                       static const unsigned LENGTH_REQUIRED            = 411;
+                       static const unsigned INTERNAL_SERVER_ERROR      = 500;
+                       static const unsigned NOT_IMPLEMENTED            = 501;
+                       static const unsigned HTTP_VERSION_NOT_SUPPORTED = 505;
+
+               /////////////////////////////////////////////////////////////////////
                // Atributos.
 
                private:
@@ -44,7 +61,7 @@ namespace Server {
                        /// Cuerpo del mensaje.
                        std::string body;
 
-               protected:
+               public: // TODO hacer privados con get() y set() ???
 
                        /// Version HTTP.
                        std::string version;
@@ -52,6 +69,7 @@ namespace Server {
                        /// Cabeceras HTTP.
                        HTTPHeaders headers;
 
+               /////////////////////////////////////////////////////////////////////
                // Métodos.
 
                public:
@@ -64,13 +82,13 @@ namespace Server {
                        /**
                         * Constructor.
                         */
-                       HTTPMessage(const std::string& http_version = "1.1");
+                       //HTTPMessage(const std::string& http_version = "1.1");
 
                        /**
                         * Constructor.
                         */
-                       //HTTPMessage(const std::string& body,
-                       //              const std::string& http_version = "1.1");
+                       HTTPMessage(const std::string& _body = "",
+                                       const std::string& _version = "1.1");
 
                        /**
                         * Obtiene el cuerpo del mensaje.
@@ -95,6 +113,13 @@ namespace Server {
                        friend std::ostream& operator<<(std::ostream& os,
                                        const HTTPMessage& m);
 
+                       /**
+                        * Obtiene la razón según un código.
+                        *
+                        * \param code Código de estado.
+                        */
+                       static std::string reason(unsigned code);
+
        };
 
 }