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

Re: Returning error message from custom smart http server

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 16, 2014, 23:01 UTC
Message-ID
<20140516230116.GC180798@vauxhall.crustytoothpaste.net>
In-Reply-To
<5371CC4F.80602@intland.com>
On Tue, May 13, 2014 at 09:39:59AM +0200, "Ákos, Tajti" wrote:
Show 19 quoted lines
> Dear List,
> 
> we implemented our own git smart http server to be able to check permissions
> and other thing before pushes. It works fine, however, the error messages we
> generate on the server side are not displayed by the command line client. On
> the server we generate error messages like this:
> 
>         response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
>         response.getWriter().write(msg);
> 
> On the command line we get this:
> 
> Total 0 (delta 0), reused 0 (delta 0)
> POST git-receive-pack (290 bytes)
> efrror: RPC failed; result=22, HTTP code = 401
> atal: The remote end hung up unexpectedly
> fatal: The remote end hung up unexpectedly
> 
> The server message is completely missing. Is there a solution for this?
It does look that way.  Does the following patch work for you?
-- >8 --
Subject: [PATCH] http: provide server's error message on RPC failure

The server might provide a custom error message that is useful to the user. Provide this message to the user if HTTP RPC fails.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 remote-curl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index 52c2d96..5984d35 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -426,8 +426,8 @@ static int run_slot(struct active_request_slot *slot,
 	err = run_one_slot(slot, results);
 
 	if (err != HTTP_OK && err != HTTP_REAUTH) {
-		error("RPC failed; result=%d, HTTP code = %ld",
-		      results->curl_result, results->http_code);
+		error("RPC failed; result=%d, HTTP code = %ld (%s)",
+		      results->curl_result, results->http_code, curl_errorstr);
 	}
 
 	return err;
-- >8 --
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
Previous: Ákos, TajtiNext: Bryan Turner
Message 2 of 5 in “Returning error message from custom smart http server”
  1. Ákos, TajtiMay 13, 2014
  2. brian m. carlsonMay 16, 2014
  3. Bryan TurnerMay 19, 2014
  4. Carlos Martín NietoMay 19, 2014
  5. Jeff KingMay 19, 2014

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.