From patchwork Thu Nov 8 04:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10673471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0CAB15E9 for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDB7C2D83A for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1A5C2D88D; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 666BD2D80C for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728829AbeKHO2j (ORCPT ); Thu, 8 Nov 2018 09:28:39 -0500 Received: from mail-pf1-f181.google.com ([209.85.210.181]:44500 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbeKHO2j (ORCPT ); Thu, 8 Nov 2018 09:28:39 -0500 Received: by mail-pf1-f181.google.com with SMTP id j13-v6so8741747pff.11 for ; Wed, 07 Nov 2018 20:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=pwaq1k7tbXYZJbON+5QUf3xRvroHi6fk057jEUhtDRQ=; b=paIwGKoLC0d2GWcrSx958VCEl8HDzEkI7VdmdrV1/2Fe8oFbWBdU9hEXeH5sVxClN7 giiwGvH/SOeQTp3xJPyqs061cuL3u0S5PF/5m3JuMWN/WvkMcJ8FasSgBXgR+XHYfQMx NoAZxm8XH5ivpzd8phw0P9ZWmWYfqPNvBCdl/gXQM1/ul1ccJINCCsUzBrHAIIVeMho1 oV5k5tMtXKQRKfH3++RW+1E98KfCWYB+AEYtm6JjN7pZAhjgknX6dfq8Gu8gSRVWMG6M Gq6vpKFAnyRQEQECJzL7sJQKSjVDGGeflwEVIGK7hKuk0wN6/DGykdHQtU8NEIfQgs5G HUfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=pwaq1k7tbXYZJbON+5QUf3xRvroHi6fk057jEUhtDRQ=; b=rKTqBbrSfsBv9MO6QWdcEpagXKKsC5in4Dsqh4QwKIHYBL8VLkW01vJCJqYh+f6Lxt Sfhd1ugx3ExTjpDzysoVRJDwfSHmu8EJsSzvogBFZLHHqFHdpcU23r/oRlfDC3b8T3EW jNjF7r5mzxVQ+m5e8o/5DvswhesQ+ocLVKYutTD8Y0T1QKZZZR9lljA3dnRjslNHSYUm SYm2I22q4aFuzCbCe9OVJngoBjjBd7Y2xNdT3gb9QsWnXNjQGLGr6CuWPPz6qhJTTEpg QANVyR42CxbbXTSrPb+ea9dNdgm7YziotGvOsDL3o4TtInTw+uPwtqSQz/KH81GV3JYs MrAg== X-Gm-Message-State: AGRZ1gLZjrdMbJ622URf3CXa2Q3eR98HDj2AXPhcti4lBtuPpShZwu9e ip1el7n5xz+i+g1EPwiQD4FogX51 X-Google-Smtp-Source: AJdET5cK1Hse44dOzx1RNk3P6RmGOuiPC/FmWhyZGrpce7gArYN+PsFJgEA8OXdxCO6gHDLU0QZtHw== X-Received: by 2002:a65:42c2:: with SMTP id l2-v6mr2532940pgp.139.1541652899820; Wed, 07 Nov 2018 20:54:59 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id q195sm2329266pgq.7.2018.11.07.20.54.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 20:54:59 -0800 (PST) Date: Wed, 07 Nov 2018 20:54:59 -0800 (PST) X-Google-Original-Date: Thu, 08 Nov 2018 04:54:52 GMT Message-Id: <4f5a935c4355794effb23c979dcbaf77ed33da26.1541652896.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Force Charlie via GitGitGadget" Subject: [PATCH v3 1/4] http: add support selecting http version Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Force Charlie Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Force Charlie Signed-off-by: Force Charlie --- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/http.c b/http.c index 3dc8c560d6..99cb04faba 100644 --- a/http.c +++ b/http.c @@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE]; static int curl_ssl_verify = -1; static int curl_ssl_try; +static int curl_http_version = 11; static const char *ssl_cert; static const char *ssl_cipherlist; static const char *ssl_version; @@ -284,6 +285,10 @@ static void process_curl_messages(void) static int http_options(const char *var, const char *value, void *cb) { + if (!strcmp("http.version",var)) { + curl_http_version=git_config_int(var,value); + return 0; + } if (!strcmp("http.sslverify", var)) { curl_ssl_verify = git_config_bool(var, value); return 0; @@ -806,6 +811,13 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2); } +#if LIBCURL_VERSION_NUM >= 0x073100 + if(curl_http_version == 20){ + /* CURL Enable HTTP2*/ + curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2); + } +#endif + #if LIBCURL_VERSION_NUM >= 0x070907 curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); #endif From patchwork Thu Nov 8 04:55:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10673473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E21514E2 for ; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F24562D833 for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6BC62D859; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 872502D833 for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728836AbeKHO2k (ORCPT ); Thu, 8 Nov 2018 09:28:40 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35291 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbeKHO2k (ORCPT ); Thu, 8 Nov 2018 09:28:40 -0500 Received: by mail-pg1-f194.google.com with SMTP id 32-v6so8333613pgu.2 for ; Wed, 07 Nov 2018 20:55:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=TEACPUbf9LKilUsENgqE1AsKA4VNCAyaGbrfWRTpqTs=; b=pa8ckZ5SJ1SyZxz4dC/o+fkC4L+IcPGOGT7Ob+cZy+vNyusQAUr1BH2+YHZOvsftdM NSmWQ9OIiXa13jByVMVxdZDpa8220u9gyC0+ypXNHsFBq+LLZ3RRZTMhhx/oxlMsTVWj 74JJ17DYWm8EfzmEyRfv4TsiwewSIyKajSAYI4p4HVP43bKZE4fIQdjJxAZry78fKT/T L3hTouzxnRm90Ss7zRYoeirzf/zAubqgh1b2TdHRqTWc9DI9txpAhdw37lbOnbKrX8JD 3pZIAuOMAqYlLlAI1kLtHhCMedZFXUPD5198iRBcKHH5HO8yvgRLSnhiF7jyEeg4TrCI nt4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=TEACPUbf9LKilUsENgqE1AsKA4VNCAyaGbrfWRTpqTs=; b=XHTZ8js3nvbqnKlaFL0jIoTDiKdi9dldIY+LP32tM5BuhgBpYrP4uR7A6hYeChKrFT TKHr9P2JcvFMRdaUwfDIXrpyfh5GmHRiy/Vw9F9eF8nAvCUkzsC58GN2pFKypxhxsAYR OLzDgEocJsgk905j45hu6gt5MYdZdDl3GTFueADJDwmh9accXfnfsfMQ40egasP4hFcE oxGdrBZ/xOOjbdk0pvCNWssQDzLcMBLO9J/ETBGDCUdRMcXDNOsV5WFE3C2lflrQVG59 SogmE1irdmxosUV7UNUlYsu+oB636uTIbs+SL2lACNUb9cnBxjnTLh3ExxSVcttg3CMv ylmw== X-Gm-Message-State: AGRZ1gIA6R9QHV8ZQZFbMJllVEvli2Ta3jyzstHfBkIbcz0MSJjjdw+T RXcVpFMgNpmCl3GPioR4pE8wVIlo X-Google-Smtp-Source: AJdET5fReSqWWdnpNom5idl8rsUNUxbJ6NCi36anOjx59l30fkyQZC+7ngZoVWNzRxYJXreZlv/zrg== X-Received: by 2002:a63:e055:: with SMTP id n21mr2654038pgj.397.1541652901154; Wed, 07 Nov 2018 20:55:01 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id d3sm1830520pgl.64.2018.11.07.20.55.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 20:55:00 -0800 (PST) Date: Wed, 07 Nov 2018 20:55:00 -0800 (PST) X-Google-Original-Date: Thu, 08 Nov 2018 04:54:53 GMT Message-Id: <06e9685d2bcef99d6635bd928845156b1580062f.1541652896.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Force Charlie via GitGitGadget" Subject: [PATCH v3 2/4] support force use http 1.1 Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Force Charlie Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Force Charlie Signed-off-by: Force Charlie --- http.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index 99cb04faba..b2ec31aef5 100644 --- a/http.c +++ b/http.c @@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE]; static int curl_ssl_verify = -1; static int curl_ssl_try; -static int curl_http_version = 11; +static int curl_http_version = 0; static const char *ssl_cert; static const char *ssl_cipherlist; static const char *ssl_version; @@ -811,11 +811,14 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2); } -#if LIBCURL_VERSION_NUM >= 0x073100 - if(curl_http_version == 20){ - /* CURL Enable HTTP2*/ - curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2); - } +#if LIBCURL_VERSION_NUM >= 0x074700 + // curl_http_version 0 is default. + if (curl_http_version == 20) { + /* Enable HTTP2 when request TLS*/ + curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS); + } else if (curl_http_version == 11) { + curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); + } #endif #if LIBCURL_VERSION_NUM >= 0x070907 From patchwork Thu Nov 8 04:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10673475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C23D1923 for ; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CF5C2D83A for ; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11A902D833; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A74152D794 for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728871AbeKHO2l (ORCPT ); Thu, 8 Nov 2018 09:28:41 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33799 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbeKHO2k (ORCPT ); Thu, 8 Nov 2018 09:28:40 -0500 Received: by mail-pf1-f196.google.com with SMTP id y18-v6so6358953pfn.1 for ; Wed, 07 Nov 2018 20:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=LNZMhKlfrAQX+xT84qOrzO8agUCG35LSD7aXqa1Azg4=; b=DvG4u1yttnP9MOv/Hqvp+pgFvmRFSCfPC6n8XCPr5fHpzUwteJ8/dhpzvnzRGBFZ+h UJa65/YMbr/PWTgXDmj18QCPm39zr7Z2nYPAT0LtoRMKk83X6tTJ87MUdXJkP6K3sbnD EicA0MXxKmXxmqurQ9yBU7OFSVLPCuFs525Xbn64EZzfHxHKfYAFBlOuC09QiEQ/UeQV yLnCCR6q2UkJARNFnwGsuHs5x9aw/WgWma+cv+X62Sjj9ZVbUr691wEDSSDwqhvasNuT pKsWvAOUhbF+46KrE1pUqLz5uPiCJc3NCSIy1T5hJf+qtfVFZgYeMaz883TBOTWy3++Y oGMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=LNZMhKlfrAQX+xT84qOrzO8agUCG35LSD7aXqa1Azg4=; b=IkywgXQ/k9787r9cgKElKmphaakLse18vLQUuH9GDAXl/s5d9c6Wan2+RhWG6y9hTE r8SVtYGF+GqV+nqzucXZUjk0Iiamu7FtpMj2jqvTx2TxJzbWow5jKBcctgH2uyj7lKbp 6TPFd9fYYN9zs0r6UOdT0A1Qd37Unlq7+k7q9x6OuI49teEAipUHAIS2bS7X92vDJb/1 J0i4zgdrwpdEfkL03//4EI1I2bZ4/hnAyUEm96Fq7e+yZaPw1tIlUtZzia/+DeOWGnJx csASt4fU7+xnusrMry8akXATDmTwbp9sj0ffEyfF7/rb3+3mLa+/IdP2e8ubPs0LdzYq fTrA== X-Gm-Message-State: AGRZ1gKWbiHDj94nAm92hvPfyvptuXQhdC5xLmUUcOYZhhy0NN6GgCob fm9u1qfSPRQ16UiSr67Wwh2wQ99d X-Google-Smtp-Source: AJdET5eDOzdKgfIC6Nkjzqi8DdaXWUzosjUx3pnQap6IDnG+cr/TOuHZill7Ds1Tqrg52KuIioXFAA== X-Received: by 2002:a62:114c:: with SMTP id z73-v6mr3092606pfi.192.1541652902346; Wed, 07 Nov 2018 20:55:02 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id v4-v6sm2570292pff.9.2018.11.07.20.55.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 20:55:01 -0800 (PST) Date: Wed, 07 Nov 2018 20:55:01 -0800 (PST) X-Google-Original-Date: Thu, 08 Nov 2018 04:54:54 GMT Message-Id: In-Reply-To: References: From: "Force Charlie via GitGitGadget" Subject: [PATCH v3 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Force Charlie Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Force Charlie Signed-off-by: Force Charlie --- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http.c b/http.c index b2ec31aef5..86e454cff5 100644 --- a/http.c +++ b/http.c @@ -811,10 +811,10 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2); } -#if LIBCURL_VERSION_NUM >= 0x074700 +#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0 // curl_http_version 0 is default. if (curl_http_version == 20) { - /* Enable HTTP2 when request TLS*/ + /* Enable HTTP2*/ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS); } else if (curl_http_version == 11) { curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); From patchwork Thu Nov 8 04:55:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10673477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C0AC17D4 for ; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B93F2D794 for ; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 303092D833; Thu, 8 Nov 2018 04:55:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7FA62D80C for ; Thu, 8 Nov 2018 04:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728761AbeKHO2m (ORCPT ); Thu, 8 Nov 2018 09:28:42 -0500 Received: from mail-pf1-f175.google.com ([209.85.210.175]:39951 "EHLO mail-pf1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728841AbeKHO2l (ORCPT ); Thu, 8 Nov 2018 09:28:41 -0500 Received: by mail-pf1-f175.google.com with SMTP id x2-v6so4665515pfm.7 for ; Wed, 07 Nov 2018 20:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=yADFirXFZr6zO2b5q2BzJvz1g09fhbkE5G6ro00Rza8=; b=gjQTD9UXYctBuGHOT2FbMjrwilGDxecYXvsMqtfbowi4aIM0O1hSCZXMYeDKdw8d1Z 8J6/mOPOJn7/MkNUwOF+XSdHEGdQtvbGaDU/wqFx2obRX8tPlyyMViTdA0ix3aKFKlM9 4yd7wwYqiSL2zrCkAMoN6aEfwrH/cNAFsXiOQszhHwXuAS7JsmAT943RhjCkDWo+Eau5 Cpdnvzz/EuNqz81QYZmI/KH42/nC5yClm6FUc8ZrU+fz+Rbx8kEuyBzZq6tNhiShEREr oGcwp47dyfPodxIjiWLF33Q1zeFHDvBGo+g2JrqCVRqkZTh6mn5Acspjkw3Q35j/osAW TjYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=yADFirXFZr6zO2b5q2BzJvz1g09fhbkE5G6ro00Rza8=; b=aN7M7l2c67vvGvHWO7zCM+LNcF7PdqgTsPi5Fhdjt/fqz69ENvY9iNuYHiZOGto8QX 5/vyejvDAaDhj29Ycwzi89K/qdRhtUmLUDogDAPMLS+UpyaPE6XVo+/4c0LcOID16BZB qP396ShRLSHxYrEfdTSbVrUUvT+F23wYAuiBgFKd3g3EzW+Tytz39CADy60QRVh6jolJ 9Ev6N3PYBuQf6D1rvWQRLtxYLXCMM4leSwv2bbU6SzFBoNtI2Xq8OMfIYFzWk05SvDTx MsZHXTj4bJ298Ehw1f/eEnTujXlO1FAXgyJ61n17vdYJiDeWl/lECuUhRKNJwN1yfdyQ 7daw== X-Gm-Message-State: AGRZ1gKAidmYNvJVjb+Sbsl+fPzD/Y8RWAGvZoxt+jHK1kgRgiO1x4qQ fWNt7Mv9rIG7FdpNR3rOcewH5qB+ X-Google-Smtp-Source: AJdET5c4oXT5Xedg+DgUxWXUlTKyCThCnFEoepiEyKyFa65WpCcRbqW9F6h6TUYYi8kk1bLGNPnp7Q== X-Received: by 2002:a63:a552:: with SMTP id r18mr2652680pgu.176.1541652903517; Wed, 07 Nov 2018 20:55:03 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id p6-v6sm2772391pfg.30.2018.11.07.20.55.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 20:55:02 -0800 (PST) Date: Wed, 07 Nov 2018 20:55:02 -0800 (PST) X-Google-Original-Date: Thu, 08 Nov 2018 04:54:55 GMT Message-Id: In-Reply-To: References: From: "Force Charlie via GitGitGadget" Subject: [PATCH v3 4/4] http: change http.version value type Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Force Charlie Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Force Charlie Signed-off-by: Force Charlie --- http.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/http.c b/http.c index 86e454cff5..0ad797caea 100644 --- a/http.c +++ b/http.c @@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE]; static int curl_ssl_verify = -1; static int curl_ssl_try; -static int curl_http_version = 0; +static const char *curl_http_version = NULL; static const char *ssl_cert; static const char *ssl_cipherlist; static const char *ssl_version; @@ -286,8 +286,7 @@ static void process_curl_messages(void) static int http_options(const char *var, const char *value, void *cb) { if (!strcmp("http.version",var)) { - curl_http_version=git_config_int(var,value); - return 0; + return git_config_string(&curl_http_version, var, value); } if (!strcmp("http.sslverify", var)) { curl_ssl_verify = git_config_bool(var, value); @@ -794,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user) } #endif +#if LIBCURL_VERSION_NUM >=0x072f00 +static int get_curl_http_version_opt(const char *version_string, long *opt) +{ + int i; + static struct { + const char *name; + long opt_token; + } choice[] = { + { "HTTP/1.1", CURL_HTTP_VERSION_1_1 }, + { "HTTP/2", CURL_HTTP_VERSION_2 } + }; + + for (i = 0; i < ARRAY_SIZE(choice); i++) { + if (!strcmp(version_string, choice[i].name)) { + *opt = choice[i].opt_token; + return 0; + } + } + + return -1; /* not found */ +} + +#endif + static CURL *get_curl_handle(void) { CURL *result = curl_easy_init(); @@ -812,12 +835,10 @@ static CURL *get_curl_handle(void) } #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0 - // curl_http_version 0 is default. - if (curl_http_version == 20) { - /* Enable HTTP2*/ - curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS); - } else if (curl_http_version == 11) { - curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); + long opt=-1; + if (curl_http_version &&!get_curl_http_version_opt(curl_http_version, &opt)) { + /* Set request use http version */ + curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt); } #endif