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

Re: [PATCH 2/6] http: handle proxy proactive authentication

From
NLNelson Benitez Leon <nelsonjesus.benitez@seap.minhap.es>
Date
May 4, 2012, 11:10 UTC
Message-ID
<4FA3B92E.3000200@seap.minhap.es>
In-Reply-To
<20120504071632.GB21895@sigill.intra.peff.net>
On 05/04/2012 09:16 AM, Jeff King wrote:
Show 37 quoted lines
> On Thu, May 03, 2012 at 06:39:54PM +0200, Nelson Benitez Leon wrote:
> 
>> If http_proactive_auth flag is set and there is a username
>> but no password in the proxy url, then interactively ask for
>> the password.
>>
>> This makes possible to not have the password written down in
>> http_proxy env var or in http.proxy config option.
>>
>> Also take care that CURLOPT_PROXY don't include username or
>> password, as we now set them in the new set_proxy_auth() function
>> where we use their specific cURL options.
> 
> Do we actually need to do that? If we set CURLOPT_PROXYUSERNAME, will
> curl ignore it in favor of what's in the URL? I ask, because there is a
> bug here:
> 
>> @@ -351,8 +366,19 @@ static CURL *get_curl_handle(const char *url)
>>  	}
>>  	
>>  	if (curl_http_proxy) {
>> -		curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
>> +		struct strbuf proxyhost = STRBUF_INIT;
>> +
>> +		if (!proxy_auth.host) /* check to parse only once */
>> +			credential_from_url(&proxy_auth, curl_http_proxy);
>> +
>> +		if (http_proactive_auth && proxy_auth.username && !proxy_auth.password)
>> +			/* proxy string has username but no password, ask for password */
>> +			credential_fill(&proxy_auth);
>> +
>> +		strbuf_addf(&proxyhost, "%s://%s", proxy_auth.protocol, proxy_auth.host);
>> +		curl_easy_setopt(result, CURLOPT_PROXY, strbuf_detach(&proxyhost, NULL));
> 
> When you parse the URL via credential_from_url, the components you get
> will have any URL-encoding removed. So when you regenerate the URL in
> the proxyhost variable, you would need to re-encode.

Can a hostname has url-encoded parts? I thought that was only for the request uri (/somedir/somefile.php) or the query string ('?var1=val'), I'm only using the hostname here as a proxy server never has more than that, apart from the port number.

Previous: Jeff KingNext: Jeff King
Message 3 of 6 in “http: handle proxy proactive authentication”
  1. 2/6 http: handle proxy proactive authenticationNelson Benitez Leon, May 3, 2012
  2. Jeff KingMay 4, 2012
  3. Nelson Benitez LeonMay 4, 2012
  4. Jeff KingMay 4, 2012
  5. Nelson Benitez LeonMay 4, 2012
  6. Jeff KingMay 4, 2012

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.