git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] http: support CURLPROXY_HTTPS
@ 2017-12-19 17:24 Wei Shuyu
  2017-12-19 20:59 ` Jonathan Nieder
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Shuyu @ 2017-12-19 17:24 UTC (permalink / raw)
  To: git; +Cc: Wei Shuyu, gitster

HTTP proxy over SSL is supported by curl since 7.52.0.
This is very useful for networks with protocol whitelist.

Signed-off-by: Wei Shuyu <wsy@dogben.com>
---
 http.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/http.c b/http.c
index 215bebef1..32d33261c 100644
--- a/http.c
+++ b/http.c
@@ -865,6 +865,11 @@ static CURL *get_curl_handle(void)
 		else if (starts_with(curl_http_proxy, "socks"))
 			curl_easy_setopt(result,
 				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x073400
+		else if (starts_with(curl_http_proxy, "https"))
+			curl_easy_setopt(result,
+				CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
 #endif
 		if (strstr(curl_http_proxy, "://"))
 			credential_from_url(&proxy_auth, curl_http_proxy);
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] http: support CURLPROXY_HTTPS
  2017-12-19 17:24 [PATCH] http: support CURLPROXY_HTTPS Wei Shuyu
@ 2017-12-19 20:59 ` Jonathan Nieder
  2017-12-19 21:38   ` Junio C Hamano
       [not found]   ` <a572179929e666e4e598930ec774c4db@dogben.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Nieder @ 2017-12-19 20:59 UTC (permalink / raw)
  To: Wei Shuyu; +Cc: git, gitster, Jeff King

Hi,

Wei Shuyu wrote:

> HTTP proxy over SSL is supported by curl since 7.52.0.
> This is very useful for networks with protocol whitelist.
>
> Signed-off-by: Wei Shuyu <wsy@dogben.com>
> ---
>  http.c | 5 +++++
>  1 file changed, 5 insertions(+)

Thanks for writing this.  Can you give an example of how I'd use it
(ideally in the form of a test in t/ so we avoid this functionality
regressing, but if that's not straightforward then an example for the
commit message is fine as well)?

> diff --git a/http.c b/http.c
> index 215bebef1..32d33261c 100644
> --- a/http.c
> +++ b/http.c
> @@ -865,6 +865,11 @@ static CURL *get_curl_handle(void)
>  		else if (starts_with(curl_http_proxy, "socks"))
>  			curl_easy_setopt(result,
>  				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
> +#endif
> +#if LIBCURL_VERSION_NUM >= 0x073400

Can this use #ifdef CURLPROXY_HTTPS instead?  That way, if someone's
copy of curl has backported support then they get the benefit of this
change as well.

> +		else if (starts_with(curl_http_proxy, "https"))
> +			curl_easy_setopt(result,
> +				CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
>  #endif
>  		if (strstr(curl_http_proxy, "://"))
>  			credential_from_url(&proxy_auth, curl_http_proxy);

Thanks and hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] http: support CURLPROXY_HTTPS
  2017-12-19 20:59 ` Jonathan Nieder
@ 2017-12-19 21:38   ` Junio C Hamano
  2017-12-19 21:50     ` Jonathan Nieder
       [not found]   ` <a572179929e666e4e598930ec774c4db@dogben.com>
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2017-12-19 21:38 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Wei Shuyu, git, Jeff King

Jonathan Nieder <jrnieder@gmail.com> writes:

> Hi,
>
> Wei Shuyu wrote:
>
>> HTTP proxy over SSL is supported by curl since 7.52.0.
>> This is very useful for networks with protocol whitelist.
>>
>> Signed-off-by: Wei Shuyu <wsy@dogben.com>
>> ---
>>  http.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> Thanks for writing this.  Can you give an example of how I'd use it
> (ideally in the form of a test in t/ so we avoid this functionality
> regressing, but if that's not straightforward then an example for the
> commit message is fine as well)?

Just FYI, here is an entry I added to the What's cooking report
(which will be used as the log message for a merge commit that pulls
this topic in, and will become an entry in the release notes if this
topic ever becomes a part of a release).

 Git has been taught to support an https:// used for http.proxy when
 using recent versions of libcurl.

There are multiple ways other than http.proxy configuration variable
that a user can use to tell Git to use a proxy; I do not think the
log message of this change is a place to enumerate all of them, but
showing one of them to the readers would be good to remind them what
we are talking about, I would guess.

>> diff --git a/http.c b/http.c
>> index 215bebef1..32d33261c 100644
>> --- a/http.c
>> +++ b/http.c
>> @@ -865,6 +865,11 @@ static CURL *get_curl_handle(void)
>>  		else if (starts_with(curl_http_proxy, "socks"))
>>  			curl_easy_setopt(result,
>>  				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
>> +#endif
>> +#if LIBCURL_VERSION_NUM >= 0x073400
>
> Can this use #ifdef CURLPROXY_HTTPS instead?  That way, if someone's
> copy of curl has backported support then they get the benefit of this
> change as well.

It sounds like a worthwhile thing to do (assuming that these are
always implemented as preprocessor macros).

>> +		else if (starts_with(curl_http_proxy, "https"))
>> +			curl_easy_setopt(result,
>> +				CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
>>  #endif
>>  		if (strstr(curl_http_proxy, "://"))
>>  			credential_from_url(&proxy_auth, curl_http_proxy);
>
> Thanks and hope that helps,
> Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] http: support CURLPROXY_HTTPS
  2017-12-19 21:38   ` Junio C Hamano
@ 2017-12-19 21:50     ` Jonathan Nieder
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Nieder @ 2017-12-19 21:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Wei Shuyu, git, Jeff King

Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>> Wei Shuyu wrote:

>>> diff --git a/http.c b/http.c
>>> index 215bebef1..32d33261c 100644
>>> --- a/http.c
>>> +++ b/http.c
>>> @@ -865,6 +865,11 @@ static CURL *get_curl_handle(void)
>>>  		else if (starts_with(curl_http_proxy, "socks"))
>>>  			curl_easy_setopt(result,
>>>  				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
>>> +#endif
>>> +#if LIBCURL_VERSION_NUM >= 0x073400
>>
>> Can this use #ifdef CURLPROXY_HTTPS instead?  That way, if someone's
>> copy of curl has backported support then they get the benefit of this
>> change as well.
>
> It sounds like a worthwhile thing to do (assuming that these are
> always implemented as preprocessor macros).

Oh, good point!  It's an enumerator, not a preprocessor macro.  But
there is a preprocessor macro CURL_VERSION_HTTPS_PROXY.

Anyway, using LIBCURL_VERSION_NUM is consistent with the surrounding
code.

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] http: support CURLPROXY_HTTPS
       [not found]   ` <a572179929e666e4e598930ec774c4db@dogben.com>
@ 2017-12-20  2:30     ` Wei Shuyu
  2017-12-20 11:41     ` Jeff King
  1 sibling, 0 replies; 6+ messages in thread
From: Wei Shuyu @ 2017-12-20  2:30 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, gitster, Jeff King

On 2017-12-20 10:22, Wei Shuyu wrote:

> CURLPROXY_HTTPS is intended for run-time detection. I don't think it's 
> a
> good idea to use it with #ifdef.

s/CURLPROXY_HTTPS/CURL_VERSION_HTTPS_PROXY/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] http: support CURLPROXY_HTTPS
       [not found]   ` <a572179929e666e4e598930ec774c4db@dogben.com>
  2017-12-20  2:30     ` Wei Shuyu
@ 2017-12-20 11:41     ` Jeff King
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2017-12-20 11:41 UTC (permalink / raw)
  To: Wei Shuyu; +Cc: Jonathan Nieder, git, gitster

On Wed, Dec 20, 2017 at 10:22:06AM +0800, Wei Shuyu wrote:

> On 2017-12-20 04:59, Jonathan Nieder wrote:
> 
> > Thanks for writing this.  Can you give an example of how I'd use it
> > (ideally in the form of a test in t/ so we avoid this functionality
> > regressing, but if that's not straightforward then an example for the
> > commit message is fine as well)?
> 
> Hi Jonathan,
> Its usage is the same as other protocols. Just set http.proxy or
> http_proxy/https_proxy
> environment to https://url.
> 
> To use apache server as a proxy, just add `ProxyRequests On` to an https
> site.

Unfortunately I don't think we have any proxy tests at all in our test
suite right now. The sticking point is that we need an actual proxy to
test against. :)

If it really is as simple as "ProxyRequests On", then we might be able
to convince the existing apache process we run to proxy requests to
itself (perhaps on a secondary port?).

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-20 11:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 17:24 [PATCH] http: support CURLPROXY_HTTPS Wei Shuyu
2017-12-19 20:59 ` Jonathan Nieder
2017-12-19 21:38   ` Junio C Hamano
2017-12-19 21:50     ` Jonathan Nieder
     [not found]   ` <a572179929e666e4e598930ec774c4db@dogben.com>
2017-12-20  2:30     ` Wei Shuyu
2017-12-20 11:41     ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).