Skip to content

Commit 0054045

Browse files
spearcegitster
authored andcommitted
remote-curl: include curl_errorstr on SSL setup failures
For curl error 35 (CURLE_SSL_CONNECT_ERROR) users need the additional text stored in CURLOPT_ERRORBUFFER to debug why the connection did not start. This is curl_errorstr inside of http.c, so include that in the message if it is non-empty. Sometimes HTTP response codes aren't yet available, such as when the SSL setup fails. Don't include HTTP 0 in the message. Signed-off-by: Shawn Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a08595f commit 0054045

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

remote-curl.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,20 @@ static int run_slot(struct active_request_slot *slot,
439439
err = run_one_slot(slot, results);
440440

441441
if (err != HTTP_OK && err != HTTP_REAUTH) {
442-
error("RPC failed; result=%d, HTTP code = %ld",
443-
results->curl_result, results->http_code);
442+
struct strbuf msg = STRBUF_INIT;
443+
if (results->http_code && results->http_code != 200)
444+
strbuf_addf(&msg, "HTTP %ld", results->http_code);
445+
if (results->curl_result != CURLE_OK) {
446+
if (msg.len)
447+
strbuf_addch(&msg, ' ');
448+
strbuf_addf(&msg, "curl %d", results->curl_result);
449+
if (curl_errorstr[0]) {
450+
strbuf_addch(&msg, ' ');
451+
strbuf_addstr(&msg, curl_errorstr);
452+
}
453+
}
454+
error("RPC failed; %s", msg.buf);
455+
strbuf_release(&msg);
444456
}
445457

446458
return err;

0 commit comments

Comments
 (0)