From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 32E73430D5A for ; Mon, 28 Oct 2019 18:52:02 +0300 (MSK) From: Ilya Kosarev Date: Mon, 28 Oct 2019 18:51:48 +0300 Message-Id: <34286a5a167256f11a6bc1caa61dccf381db26c3.1572276894.git.i.kosarev@tarantool.org> In-Reply-To: References: In-Reply-To: References: Subject: [Tarantool-patches] [PATCH v3 3/4] http: enrich httpc_request with curl error message buffer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@freelists.org Cc: tarantool-patches@dev.tarantool.org When processing curl request error code, we are collecting error message using curl_easy_strerror. Now we are providing more info in errmsg, which is obtained using curl_easy_setopt with CURLOPT_ERRORBUFFER option. Closes #4578 @TarantoolBot document Title: http: new field in client_object:request return table Update the documentation for client_object:request method to reflect new field errmsg in return table. It contains extended curl request error message obtained using CURLOPT_ERRORBUFFER option. See https://curl.haxx.se/libcurl/c/CURLOPT_ERRORBUFFER.html --- src/httpc.c | 1 + src/httpc.h | 5 +++++ src/lua/httpc.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/httpc.c b/src/httpc.c index 22b54d16a..b493a8498 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -398,6 +398,7 @@ httpc_execute(struct httpc_request *req, double timeout) curl_easy_setopt(req->curl_request.easy, CURLOPT_HEADERDATA, (void *) req); curl_easy_setopt(req->curl_request.easy, CURLOPT_PRIVATE, (void *) &req->curl_request); curl_easy_setopt(req->curl_request.easy, CURLOPT_HTTPHEADER, req->headers); + curl_easy_setopt(req->curl_request.easy, CURLOPT_ERRORBUFFER, req->errmsg); ++env->stat.total_requests; diff --git a/src/httpc.h b/src/httpc.h index f710b3d13..145b59929 100644 --- a/src/httpc.h +++ b/src/httpc.h @@ -105,6 +105,11 @@ struct httpc_request { int status; /** Error message */ const char *reason; + /** + * Buffer for error message obtained using + * CURLOPT_ERRORBUFFER option. + */ + const char errmsg[CURL_ERROR_SIZE]; /** buffer of headers */ struct region resp_headers; /** buffer of body */ diff --git a/src/lua/httpc.c b/src/lua/httpc.c index 6ed4eb788..9fb8e4801 100644 --- a/src/lua/httpc.c +++ b/src/lua/httpc.c @@ -335,6 +335,10 @@ luaT_httpc_request(lua_State *L) lua_pushstring(L, req->reason); lua_settable(L, -3); + lua_pushstring(L, "errmsg"); + lua_pushstring(L, req->errmsg); + lua_settable(L, -3); + size_t headers_len = region_used(&req->resp_headers); if (headers_len > 0) { char *headers = region_join(&req->resp_headers, headers_len); -- 2.17.1