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

Re: [PATCH 7/8] http: factor out http error code handling

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2012, 18:06 UTC
Message-ID
<7vd32a28n7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120827132604.GG17375@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 42 quoted lines
> Most of our http requests go through the http_request()
> interface, which does some nice post-processing on the
> results. In particular, it handles prompting for missing
> credentials as well as approving and rejecting valid or
> invalid credentials. Unfortunately, it only handles GET
> requests. Making it handle POSTs would be quite complex, so
> let's pull result handling code into its own function so
> that it can be reused from the POST code paths.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  http.c | 51 ++++++++++++++++++++++++++++-----------------------
>  http.h |  1 +
>  2 files changed, 29 insertions(+), 23 deletions(-)
>
> diff --git a/http.c b/http.c
> index b61ac85..6793137 100644
> --- a/http.c
> +++ b/http.c
> @@ -745,6 +745,33 @@ char *get_remote_object_url(const char *url, const char *hex,
>  	return strbuf_detach(&buf, NULL);
>  }
>  
> +int handle_curl_result(struct active_request_slot *slot)
> +{
> +	struct slot_results *results = slot->results;
> +
> +	if (results->curl_result == CURLE_OK) {
> +		credential_approve(&http_auth);
> +		return HTTP_OK;
> +	} else if (missing_target(results))
> +...
> +		return HTTP_ERROR;
> +	}
> +}
> +
> @@ -820,9 +828,6 @@ static int http_request(const char *url, void *result, int target, int options)
>  	curl_slist_free_all(headers);
>  	strbuf_release(&buf);
>  
> -	if (ret == HTTP_OK)
> -		credential_approve(&http_auth);

OK, now this is part of handle_curl_result() so the caller does not have to worry about it, which is nice ;-)

>  	return ret;
>  }
Previous: Jeff KingNext: Jeff King
Message 15 of 22 in “git no longer prompting for password”
  1. Iain PatonAug 24, 2012
  2. Jeff KingAug 24, 2012
  3. Jeff KingAug 25, 2012
  4. Iain PatonAug 26, 2012
  5. Jeff KingAug 26, 2012
  6. Iain PatonAug 26, 2012
  7. 0/8 fix password prompting for "half-auth" serversJeff King, Aug 27, 2012
  8. 1/8 t5550: put auth-required repo in auth/dumbJeff King, Aug 27, 2012
  9. 2/8 t5550: factor out http auth setupJeff King, Aug 27, 2012
  10. 3/8 t/lib-httpd: only route auth/dumb to dumb reposJeff King, Aug 27, 2012
  11. 4/8 t/lib-httpd: recognize */smart/* repos as smart-httpJeff King, Aug 27, 2012
  12. 5/8 t: test basic smart-http authenticationJeff King, Aug 27, 2012
  13. 6/8 t: test http access to "half-auth" repositoriesJeff King, Aug 27, 2012
  14. 7/8 http: factor out http error code handlingJeff King, Aug 27, 2012
  15. Junio C HamanoAug 28, 2012
  16. 8/8 http: prompt for credentials on failed POSTJeff King, Aug 27, 2012
  17. Junio C HamanoAug 27, 2012
  18. Jeff KingAug 27, 2012
  19. Junio C HamanoAug 27, 2012
  20. Junio C HamanoAug 27, 2012
  21. Iain PatonAug 27, 2012
  22. BJ HargraveAug 27, 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.