X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/d3ea2ff01c51df0df95cd23157267048e2c2fdcd..bcbe297964b0ad7393385f1dd240448c340ed5ed:/Server/src/httpheaders.cpp diff --git a/Server/src/httpheaders.cpp b/Server/src/httpheaders.cpp index 8ebb3a7..04bd6c8 100644 --- a/Server/src/httpheaders.cpp +++ b/Server/src/httpheaders.cpp @@ -26,6 +26,7 @@ // #include "plaqui/server/httpheaders.h" +#include "plaqui/server/httperror.h" #include "plaqui/server/string.h" //#include #ifdef DEBUG @@ -44,7 +45,7 @@ HTTPHeaders::~HTTPHeaders(void) { #endif // DEBUG } -istream& operator>>(istream& is, HTTPHeaders& h) { +istream& operator>>(istream& is, HTTPHeaders& h) throw(HTTPError) { #ifdef DEBUG cerr << __FILE__ << ": operator>>()" << endl; #endif // DEBUG @@ -54,9 +55,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 HTTPError(400, sbuf + ": No es una cabecera vĂ¡lida."); } 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; } @@ -66,7 +71,7 @@ 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 << "\n\r"; + os << i->first << ": " << i->second << "\r\n"; } return os; }