git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http: do not ignore proxy path

From
Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
Date
Jul 26, 2024, 17:12 UTC
Message-ID
<6b408a07-f2ff-1e04-5b3a-fd287fb1c151@alum.mit.edu>
In-Reply-To
<xmqqr0bgw1z1.fsf@gitster.g>
At 2024-07-26 09:29-0700, Junio C Hamano <gitster@pobox.com> sent:
Show 6 quoted lines
> http.proxy documentation says
>
>  The syntax thus is [protocol://][user[:password]@]proxyhost[:port].
>
> but the updated code pays attention to what can come after the
> "host[:post]" part, does it not?
Correct; I'll add a "[/path]" to that construction.
Show 22 quoted lines
>> +		if (proxy_auth.path) {
>> +			struct strbuf proxy = STRBUF_INIT;
>> +			strbuf_addf(&proxy, "%s/%s", proxy_auth.host, proxy_auth.path);
>> +			curl_easy_setopt(result, CURLOPT_PROXY, proxy.buf);
>> +			strbuf_release(&proxy);
>> +		} else
>> +			curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
>
> Style.  If "if" side needs {braces} because it consists of multiple
> statements, the corresponding "else" side should also have {braces}
> around its body, even if it only has a single statement.
>
> If you have the proxy strbuf in a bit wider scope, then the above becomes
>
> 	if (proxy_auth.path)
> 		strbuf_addf(&proxy, "%s/%s", proxy_auth.host, proxy_auth.path);
> 	else
> 		strbuf_addstr(&proxy, proxy_auth.host);
> 	curl_easy_setopt(result, CURLOPT_PROXY, proxy.buf);
> 	strbuf_release(&proxy);
>
> which might (I am not decided) be easier to follow.

For what it's worth, I was following the precedent set by the if-statement starting at line 1256 (a few lines above this patch):

Show 8 quoted lines
> 		if (strstr(curl_http_proxy, "://"))
> 			credential_from_url(&proxy_auth, curl_http_proxy);
> 		else {
> 			struct strbuf url = STRBUF_INIT;
> 			strbuf_addf(&url, "http://%s", curl_http_proxy);
> 			credential_from_url(&proxy_auth, url.buf);
> 			strbuf_release(&url);
> 		}
<https://github.com/git/git/blob/ad57f148c6b5f8735b62238dda8f571c582e0e54/http.c#L1256>

I have no problem with being inconsistent with surrounding code in these style choices; just let me know what I should do in light of that.

> Could existing users have been taking advantage of the fact that the
> extra /path at the end of http.proxy (and $http_proxy and friends)
> are ignored?  For them, this change will appear as a regression.

That is possible, though I have difficulty imagining a scenario in which it would be intentional.

What do you recommend I do about that possibility?
R
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 31 in “http: do not ignore proxy path”
  1. http: do not ignore proxy pathRyan Hendrickson via GitGitGadget, Jul 26, 2024
  2. Junio C HamanoJul 26, 2024
  3. Ryan HendricksonJul 26, 2024
  4. Junio C HamanoJul 26, 2024
  5. Jeff KingJul 26, 2024
  6. Ryan HendricksonJul 26, 2024
  7. Jeff KingJul 29, 2024
  8. http: do not ignore proxy pathRyan Hendrickson via GitGitGadget, Jul 27, 2024
  9. Jeff KingJul 29, 2024
  10. Ryan HendricksonJul 31, 2024
  11. http: do not ignore proxy pathRyan Hendrickson via GitGitGadget, Jul 31, 2024
  12. Junio C HamanoJul 31, 2024
  13. Ryan HendricksonAug 1, 2024
  14. Junio C HamanoAug 1, 2024
  15. Jeff KingAug 1, 2024
  16. Junio C HamanoAug 1, 2024
  17. http: do not ignore proxy pathRyan Hendrickson via GitGitGadget, Aug 1, 2024
  18. Jeff KingAug 1, 2024
  19. Junio C HamanoAug 1, 2024
  20. http: do not ignore proxy pathRyan Hendrickson via GitGitGadget, Aug 2, 2024
  21. Junio C HamanoAug 2, 2024
  22. Ryan HendricksonAug 2, 2024
  23. Junio C HamanoAug 2, 2024
  24. Ryan HendricksonAug 2, 2024
  25. Junio C HamanoAug 2, 2024
  26. Ryan HendricksonAug 2, 2024
  27. Junio C HamanoAug 2, 2024
  28. Ryan HendricksonAug 2, 2024
  29. Junio C HamanoAug 2, 2024
  30. Junio C HamanoAug 2, 2024
  31. Ryan HendricksonAug 2, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.