git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add ERR support to smart HTTP
@ 2010-09-05 17:30 Ilari Liusvaara
  2010-09-05 17:41 ` Jonathan Nieder
  0 siblings, 1 reply; 18+ messages in thread
From: Ilari Liusvaara @ 2010-09-05 17:30 UTC (permalink / raw)
  To: git

All "true smart transports" support ERR packets, allowing server
to send back error message explaining reasons for refusing the
request instead of just rudely closing connection without any error.

However, since smart HTTP isn't "true smart transport", but instead
dumb one from git main executable perspective, smart HTTP needs to
implement its own version of this.

Now that Gitolite supports HTTP too, it needs to be able to send
error messages for authorization failures back to client so that's
one probable user for this feature.

The error is sent as '<packetlength># ERR <message>" and must be the
first packet in response. The reason for putting the '#' there is that
old git versions will interpret that as invalid server response and
print (at least the first line of) the error together with complaint
of invalid response (mangling it a bit but it will still be understandable,
in manner similar to existing smart transport ERR messages).

Thus for example server response:

"0031# ERR W access for foo/alice/a1 DENIED to bob"

Will cause the following to be printed:

"fatal: remote error: W access for foo/alice/a1 DENIED to bob"

If the git version is old and doesn't support this feature, then the
message will be:

"fatal: invalid server response; got '# ERR W access for foo/alice/a1
DENIED to bob'"

Which is at least undertandable.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 remote-curl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index 24fbb9a..46fa971 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -153,6 +153,8 @@ static struct discovery* discover_refs(const char *service)
 
 		if (packet_get_line(&buffer, &last->buf, &last->len) <= 0)
 			die("%s has invalid packet header", refs_url);
+		if (buffer.len >= 6 && !strncmp(buffer.buf, "# ERR ", 6))
+			die("remote error: %s", buffer.buf + 6);
 		if (buffer.len && buffer.buf[buffer.len - 1] == '\n')
 			strbuf_setlen(&buffer, buffer.len - 1);
 
-- 
1.7.2.4.g27652

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

end of thread, other threads:[~2010-09-08 14:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 17:30 [PATCH] Add ERR support to smart HTTP Ilari Liusvaara
2010-09-05 17:41 ` Jonathan Nieder
2010-09-05 18:49   ` Ilari Liusvaara
2010-09-05 19:27     ` Ævar Arnfjörð Bjarmason
2010-09-05 21:21       ` Ilari Liusvaara
2010-09-05 21:22       ` Jakub Narebski
2010-09-06  1:04         ` Sitaram Chamarty
2010-09-06  5:45           ` Sitaram Chamarty
2010-09-06  8:45             ` Ævar Arnfjörð Bjarmason
2010-09-06  8:49             ` Jakub Narebski
2010-09-06  9:15               ` Joshua Juran
2010-09-06 14:56                 ` Shawn O. Pearce
2010-09-06 17:59                   ` Sitaram Chamarty
2010-09-06 18:19                     ` Shawn O. Pearce
2010-09-08 14:36                       ` Sitaram Chamarty
2010-09-06 14:24               ` Sitaram Chamarty
2010-09-06 16:31                 ` Jakub Narebski
2010-09-05 20:11     ` Jonathan Nieder

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 NNTP newsgroup(s).