X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/cd6078479123cd2cfe62df2d838633c143649edf..7ef672fd3601055cca3697fd0c4d534dbb9153c5:/Server/include/plaqui/server/httpmessage.h diff --git a/Server/include/plaqui/server/httpmessage.h b/Server/include/plaqui/server/httpmessage.h index cd583e7..37c0287 100644 --- a/Server/include/plaqui/server/httpmessage.h +++ b/Server/include/plaqui/server/httpmessage.h @@ -28,6 +28,7 @@ #ifndef PLAQUI_HTTPMESSAGE_H #define PLAQUI_HTTPMESSAGE_H +#include "plaqui/server/httpheaders.h" #include namespace PlaQui { @@ -37,9 +38,30 @@ 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. - protected: + private: + + /// Cuerpo del mensaje. + std::string body; + + public: // TODO hacer privados con get() y set() ??? /// Version HTTP. std::string version; @@ -47,9 +69,7 @@ namespace Server { /// Cabeceras HTTP. HTTPHeaders headers; - /// Cuerpo del mensaje. - std::string body; - + ///////////////////////////////////////////////////////////////////// // Métodos. public: @@ -62,19 +82,30 @@ 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. + */ + const std::string& get_body(void) const; + + /** + * Establece el cuerpo del mensaje. + * + * \param _body Cuerpo del mensaje. + */ + void set_body(const std::string& _body); /** * Obtiene los datos del pedido HTTP desde un texto. */ - friend std::istream& operator>>(std::istream& is, - const HTTPMessage& m); + friend std::istream& operator>>(std::istream& is, HTTPMessage& m); /** * Convierte el pedido HTTP en texto. @@ -82,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); + }; }