X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/b92547a5de3a3fb4f14a2bea4a4e776b8da3cb5c..f27c218d18ebf7198e07249aca1eed625da914fd:/Server/src/httpheaders.cpp?ds=sidebyside diff --git a/Server/src/httpheaders.cpp b/Server/src/httpheaders.cpp index 89d8de4..0ec62e1 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 << "\r\n"; + os << i->first << ": " << i->second << "\n\r"; } return os; }