X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/cd6078479123cd2cfe62df2d838633c143649edf..9075115540d133ca048025e719884121007b9e87:/Server/include/plaqui/server/httprequest.h?ds=sidebyside diff --git a/Server/include/plaqui/server/httprequest.h b/Server/include/plaqui/server/httprequest.h index 0f21452..7b43f67 100644 --- a/Server/include/plaqui/server/httprequest.h +++ b/Server/include/plaqui/server/httprequest.h @@ -28,8 +28,12 @@ #ifndef PLAQUI_HTTPREQUEST_H #define PLAQUI_HTTPREQUEST_H -#include "httpmessage.h" +#include "plaqui/server/httperror.h" +#include "plaqui/server/httpmessage.h" +#include #include +#include +#include namespace PlaQui { @@ -38,6 +42,7 @@ namespace Server { /// Pedido HTTP. class HTTPRequest: public HTTPMessage { + ///////////////////////////////////////////////////////////////////// // Constantes. protected: @@ -69,6 +74,7 @@ namespace Server { /// Caracteres no hexa para URIs (RFC 2396). static const std::string CHARS_HEX; + ///////////////////////////////////////////////////////////////////// // Tipos. public: @@ -76,11 +82,15 @@ namespace Server { /// Tipo de métodos HTTP reconocidos. typedef enum {GET, POST} HTTPMethod; + ///////////////////////////////////////////////////////////////////// // Atributos. - protected: + protected: // TODO hacer privados con get() y set() ??? + + public: /// Método HTTP. + /// @todo TODO - convertirlo a string? Hace todo más fácil (y más ineficiente :) HTTPMethod method; /// URI. @@ -89,6 +99,7 @@ namespace Server { /// Query string. std::string query; + ///////////////////////////////////////////////////////////////////// // Métodos. public: @@ -104,19 +115,25 @@ namespace Server { HTTPRequest(const std::string& uri = "/", const HTTPMethod& method = GET, const std::string& query = "", - const std::string& http = "1.1"); + const std::string& body = "", + const std::string& version = "1.1"); + + /** + * Obtiene el método como un string. + */ + std::string method_str(void) const; /** * Obtiene los datos del pedido HTTP desde un texto. */ - friend std::istream& operator>>(std::istream& is, - const HTTPRequest& req); + friend std::istream& operator>>(std::istream& is, HTTPRequest& req) + throw(HTTPError, sockerr, std::ios::failure); /** * Convierte el pedido HTTP en texto. */ friend std::ostream& operator<<(std::ostream& os, - const HTTPRequest& req); + const HTTPRequest& req) throw(sockerr); };