X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/a143e957a68145eece4b5b60e0bf8bee0d0693cd..c0e0cf58ce033421d125afb813636f102456592c:/Server/src/httpheaders.cpp?ds=sidebyside diff --git a/Server/src/httpheaders.cpp b/Server/src/httpheaders.cpp index cef6d05..04bd6c8 100644 --- a/Server/src/httpheaders.cpp +++ b/Server/src/httpheaders.cpp @@ -26,13 +26,18 @@ // #include "plaqui/server/httpheaders.h" +#include "plaqui/server/httperror.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 @@ -40,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 @@ -50,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)] = 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; } @@ -67,3 +76,7 @@ ostream& operator<<(ostream& os, const HTTPHeaders& h) { return os; } +} // namespace Server + +} // namespace PlaQui +