HTTPRequest::~HTTPRequest(void) {
#ifdef DEBUG
- cerr << __FILE__ << ": destructor." << endl;
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": destructor." << endl;
#endif // DEBUG
}
const string& query, const string& body, const string& version):
HTTPMessage(body, version), method(method), uri(uri), query(query) {
#ifdef DEBUG
- cerr << __FILE__ << ": uri = " << uri << " | "
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": uri = " << uri << " | "
<< "method = " << method_str() << " | "
<< "query = " << query << " | "
<< "body.length = " << body.length() << " | "
}
istream& operator>>(istream& is, HTTPRequest& req)
- throw(HTTPError, ios::failure) {
+ throw(HTTPError, sockerr, ios::failure) {
#ifdef DEBUG
- cerr << __FILE__ << ": operator>>()" << endl;
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": operator>>()" << endl;
#endif // DEBUG
char buf[BUFSIZ];
// Obtengo primera línea (request)
if (!is.getline(buf, BUFSIZ)) {
- // No hay más líneas.
- throw ios::failure("socket closed");
+ // Fin de archivo.
+ throw ios::failure("eof");
}
#ifdef DEBUG
- cerr << __FILE__ << ":\tRecibiendo linea: " << buf << endl;
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ":\tRecibiendo linea: " << buf << endl;
#endif // DEBUG
String line(buf);
// Si es la primera línea, es el request.
return is;
}
-ostream& operator<<(ostream& os, const HTTPRequest& req) {
+ostream& operator<<(ostream& os, const HTTPRequest& req) throw(sockerr) {
#ifdef DEBUG
- cerr << __FILE__ << ": operator<<()" << endl;
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": operator<<()" << endl;
#endif // DEBUG
os << req.method_str() << " " << req.uri;
if (req.query.length()) {