]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/src/httprequest.cpp
* Se agrega un Tanque al ejemplo, y ANDA!!!!
[z.facultad/75.42/plaqui.git] / Server / src / httprequest.cpp
index f1119fd8d5a0b5b22dba540016bbccc471586800..d62b7859f1aa320f61f6651e69f698e2b1388ba2 100644 (file)
@@ -44,36 +44,26 @@ HTTPRequest::~HTTPRequest(void) {
 }
 
 HTTPRequest::HTTPRequest(const string& uri, const HTTPMethod& method,
-               const string& query, const string& version):
-               HTTPMessage(version), method(method), uri(uri), query(query) {
+               const string& query, const string& body, const string& version):
+               HTTPMessage(body, version), method(method), uri(uri), query(query) {
 #ifdef DEBUG
        cerr << __FILE__ << ": uri = " << uri << " | "
-                       << "method = " << ((method == GET) ? "GET" : "POST") << " | "
+                       << "method = " << method_str() << " | "
                        << "query = " << query << " | "
+                       << "body.length = " << body.length() << " | "
                        << "version = " << version << endl;
 #endif // DEBUG
 }
 
-/*
-HTTPRequest::HTTPRequest(const Serializable& body,
-               const string& version):
-               HTTPMessage(body, version) {
-#ifdef DEBUG
-       cerr << __FILE__ << ": http_version = " << http_version
-               << " | body = " << body.serialize() << endl;
-#endif // DEBUG
-}
-
-HTTPRequest::HTTPRequest(const string& uri,
-               const HTTPRequest::HTTPMethod& method,
-               string& query, string& version):
-               HTTPMessage(body, version) {
-#ifdef DEBUG
-       cerr << __FILE__ << ": http_version = " << http_version
-               << " | body = " << body.serialize() << endl;
-#endif // DEBUG
+string HTTPRequest::method_str(void) const {
+       switch (method) {
+               case POST:
+                       return "POST";
+               case GET:
+               default:
+                       return "GET";
+       }
 }
-*/
 
 istream& operator>>(istream& is, HTTPRequest& req)
                throw(HTTPError, ios::failure) {
@@ -158,12 +148,12 @@ ostream& operator<<(ostream& os, const HTTPRequest& req) {
 #ifdef DEBUG
        cerr << __FILE__ << ": operator<<()" << endl;
 #endif // DEBUG
-       os << req.method << " " << req.uri;
+       os << req.method_str() << " " << req.uri;
        if (req.query.length()) {
                os << "?" << req.query;
        }
-       // TODO ver que este bien el \n/r
-       os << " HTTP/" << req.version << "\n\r" << static_cast<const HTTPMessage&>(req);
+       os << " HTTP/" << req.version << "\r\n"
+               << static_cast<const HTTPMessage&>(req);
        return os;
 }