X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/a143e957a68145eece4b5b60e0bf8bee0d0693cd..2f5c973fdf3f7fb25b13996b66d566c58066f6a0:/Server/src/httpheaders.cpp diff --git a/Server/src/httpheaders.cpp b/Server/src/httpheaders.cpp index cef6d05..65d5adc 100644 --- a/Server/src/httpheaders.cpp +++ b/Server/src/httpheaders.cpp @@ -26,13 +26,17 @@ // #include "plaqui/server/httpheaders.h" +#include "plaqui/server/string.h" //#include #ifdef DEBUG # include #endif // DEBUG using namespace std; -using namespace PlaQui::Server; + +namespace PlaQui { + +namespace Server { HTTPHeaders::~HTTPHeaders(void) { #ifdef DEBUG @@ -50,9 +54,13 @@ istream& operator>>(istream& is, HTTPHeaders& h) { string::size_type pos = sbuf.find(":"); if (pos == string::npos) { // FIXME poner mejores excepciones. - throw "Wrong header"; + throw string("Wrong header: ") + sbuf; } - h[sbuf.substr(0, pos)] = sbuf.substr(pos + 1); + h[sbuf.substr(0, pos)] = String(sbuf.substr(pos + 1)).trim(); +#ifdef DEBUG + cerr << __FILE__ << " " << sbuf.substr(0, pos) << " = " + << h[sbuf.substr(0, pos)] << endl; +#endif // DEBUG return is; } @@ -62,8 +70,12 @@ ostream& operator<<(ostream& os, const HTTPHeaders& h) { #endif // DEBUG for (HTTPHeaders::const_iterator i = h.begin(); i != h.end(); ++i) { - os << i->first << ": " << i->second << "\r\n"; + os << i->first << ": " << i->second << "\n\r"; } return os; } +} // namespace Server + +} // namespace PlaQui +