From d45d193811431ea32217c710cecbfee3b0464a27 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 7 Oct 2013 06:20:55 +0000 Subject: [PATCH] improve error message for tracker_error_alert. various smaller attempts at making the unit tests more reliable --- src/alert.cpp | 5 ++++- test/http.py | 7 +++++-- test/setup_transfer.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index 5e2e36cd0..d699e85de 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -151,9 +151,12 @@ namespace libtorrent { std::string tracker_error_alert::message() const { char ret[400]; + std::string error_message; + if (error) error_message = error.message(); + else error_message = msg; snprintf(ret, sizeof(ret), "%s (%d) %s (%d)" , tracker_alert::message().c_str(), status_code - , msg.c_str(), times_in_row); + , error_message.c_str(), times_in_row); return ret; } diff --git a/test/http.py b/test/http.py index 3866aa98e..8dd055194 100644 --- a/test/http.py +++ b/test/http.py @@ -114,8 +114,11 @@ class ConnectionHandler: 'DELETE', 'TRACE'): self.method_others() except: - self.client.send(HTTPVER+' 502 Connection failed\n'+ - 'Proxy-agent: %s\n\n'%VERSION) + try: + self.client.send(HTTPVER+' 502 Connection failed\n'+ + 'Proxy-agent: %s\n\n'%VERSION) + except Exception, e: + print e self.client.close() return diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 118afbbf3..a702d894f 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -1313,7 +1313,7 @@ void web_server_thread(int* port, bool ssl, bool chunked) path = path.substr(1); } - fprintf(stderr, "%s: [HTTP] %s\n", time_now_string(), path.c_str()); +// fprintf(stderr, "%s: [HTTP] %s\n", time_now_string(), path.c_str()); if (path == "redirect") { @@ -1418,7 +1418,7 @@ void web_server_thread(int* port, bool ssl, bool chunked) continue; } -// fprintf(stderr, ">> serving file %s\n", path.c_str()); + DLOG(stderr, ">> serving file %s\n", path.c_str()); error_code ec; int res = load_file(path, file_buf, ec, 8000000); if (res == -1) @@ -1458,11 +1458,11 @@ void web_server_thread(int* port, bool ssl, bool chunked) extra_header[1] = eh; if (end - start + 1 >= 1000) { - fprintf(stderr, "request size: %.2f kB\n", int(end - start + 1)/1000.f); + DLOG(stderr, "request size: %.2f kB\n", int(end - start + 1)/1000.f); } else { - fprintf(stderr, "request size: %d Bytes\n", int(end - start + 1)); + DLOG(stderr, "request size: %d Bytes\n", int(end - start + 1)); } send_response(s, ec, 206, "Partial", extra_header, end - start + 1); if (!file_buf.empty())