X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/a143e957a68145eece4b5b60e0bf8bee0d0693cd..d3ea2ff01c51df0df95cd23157267048e2c2fdcd:/Server/src/httpmessage.cpp diff --git a/Server/src/httpmessage.cpp b/Server/src/httpmessage.cpp index 737f636..685fa69 100644 --- a/Server/src/httpmessage.cpp +++ b/Server/src/httpmessage.cpp @@ -33,7 +33,10 @@ #endif // DEBUG using namespace std; -using namespace PlaQui::Server; + +namespace PlaQui { + +namespace Server { HTTPMessage::~HTTPMessage(void) { #ifdef DEBUG @@ -82,9 +85,11 @@ istream& operator>>(istream& is, HTTPMessage& m) { stringstream body_ss; while (is.getline(buf, BUFSIZ)) { string sbuf = buf; - if (sbuf.length()) + if (sbuf.length()) { if (is_header) { - istringstream(buf) >> m.headers; + stringstream ss; + ss << buf; + ss >> m.headers; } else { body_ss << buf << endl; } @@ -97,15 +102,19 @@ istream& operator>>(istream& is, HTTPMessage& m) { } } // TODO si el body es un serializable, deberia auto deserializarse. - body = body_ss.str(); + m.body = body_ss.str(); return is; } -ostream& operator<<(ostream& os, HTTPMessage) { +ostream& operator<<(ostream& os, const HTTPMessage& m) { #ifdef DEBUG cerr << __FILE__ << ": operator<<()" << endl; #endif // DEBUG - return os << headers << "\r\n" // Fin de cabeceras - << body; + return os << m.headers << "\n\r" // Fin de cabeceras + << m.body; } +} // namespace Server + +} // namespace PlaQui +