From ea6125dde76ff3b35609be8e938533a14042f0c8 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 26 Nov 2016 09:42:29 +1100 Subject: [PATCH] Return the json response if there is one in a http response code failed instead of the http error. --- src/ckpool.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ckpool.c b/src/ckpool.c index d4b16b58..6b4eb4e3 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -896,6 +896,18 @@ static json_t *_json_rpc_call(connsock_t *cs, const char *rpc_req, const bool in elapsed = tvdiff(&fin_tv, &stt_tv); ASPRINTF(&warning, "HTTP response to (%.10s...) %.3fs not ok: %s", rpc_method(rpc_req), elapsed, cs->buf); + timeout = 0; + /* Look for a json response if there is one */ + while (read_socket_line(cs, &timeout) > 0) { + timeout = 0; + if (*cs->buf != '{') + continue; + free(warning); + /* Replace the warning with the json response */ + ASPRINTF(&warning, "JSON response to (%.10s...) %.3fs not ok: %s", + rpc_method(rpc_req), elapsed, cs->buf); + break; + } goto out_empty; } do {