public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce•org>
To: "H. Peter Anvin" <hpa@zytor•com>
Cc: git@vger•kernel.org
Subject: Re: Git-aware HTTP transport
Date: Tue, 26 Aug 2008 10:26:48 -0700	[thread overview]
Message-ID: <20080826172648.GK26523@spearce.org> (raw)
In-Reply-To: <48B4303C.3080409@zytor.com>

"H. Peter Anvin" <hpa@zytor•com> wrote:
> Shawn O. Pearce wrote:
>>
>> Hmm.  I'm actually thinking the exact opposite here.  My rationale
>> for putting the response as a standard HTTP 302/303 style redirect
>> is to permit hardware load balancers [...]
>> to implement simple load balancing with a HTTP redirect.
>
> No, you're thinking backwards.  What you want is the standard HTTP  
> redirect load balancing to take effect *before* the initial request is  
> serviced.
...
> Please keep in mind I'm not talking hypotheticals at all.  What you have  
> proposed is actually a lot uglier for kernel.org to implement, simply  
> because we try to stay with strict IP-based vhosting

Discard my prior patch from today.

This is a patch to last night's full document edition
(http://article.gmane.org/gmane.comp.version-control.git/93704)
and addresses only the issue of redirects.

--8<--
diff --git a/Documentation/technical/http-protocol.txt b/Documentation/technical/http-protocol.txt
index 99d7623..99dc88d 100644
--- a/Documentation/technical/http-protocol.txt
+++ b/Documentation/technical/http-protocol.txt
@@ -43,14 +43,34 @@ All requests/responses use "application/x-git" as the content type.
 Action specific subtypes are specified by the parameter "service",
 e.g. "application/x-git; service=upload-pack".
 
+HTTP Redirects
+--------------
+
+If a POST request results in an HTTP 302 or 303 redirect response
+clients should retry the request by updating the URL and POSTing
+the same request to the new location.  Subsequent requests should
+still be sent to the original URL.
+
 Detecting Smart Servers
 -----------------------
 
 HTTP clients can detect a smart Git-aware server by sending
 a request to service "show-ref".
 
-A Git-aware server will respond with a valid response (see below).
-A dumb server should respond with an error message. 
+A Git-aware server will respond with a valid response.  Clients
+must check the following properties to prevent being fooled by
+misconfigured servers:
+
+  * HTTP status code is 200.
+  * Content-Type is "application/x-git; service=show-ref"
+  * The body can be parsed without errors.  The length of
+    each pkt-line must be 4 valid hex digits.
+
+A dumb server will respond with a non-200 HTTP status code.
+A misconfigured server may respond with a normal 200 status
+code, but an incorrect content type, or an invalid leading
+4 byte sequence for a pkt-line (e.g. "<htm" or "<!DO" are
+not valid lengths).
 
 Service show-ref
 ----------------
@@ -62,15 +82,46 @@ Content-Type: application/x-git; service=show-ref
 
 The request is an empty body.
 
-The response is a sequence of refs, one per Git packet line.
-The final packet line has a length of 0 to indicate the end.
+The response is a pkt-line with "refs", followed by zero
+or more ref pkt-lines ("$id $name"), and a final pkt-line
+with a length of 0:
 
+	S: 0009refs
 	S: 003295dcfa3633004da0049d3d0fa03f80589cbcaf31 HEAD
 	S: 003e95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
 	S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
 	S: 003b2cb58b79488a98d2721cea644875a8dd0026b115 refs/heads/pu
 	S: 0000
 
+The response may begin with an optional redirect to a new service
+URL for the repository:
+
+	S: 0028redirect http://s1.example.com/git/
+	S: 0009refs
+	S: 003295dcfa3633004da0049d3d0fa03f80589cbcaf31 HEAD
+	S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
+	S: 0000
+
+or be composed of only a redirect:
+
+	S: 0028redirect http://s1.example.com/git/
+	S: 0000
+
+If a redirect is returned the client should update itself
+to use the new URL as the location for future requests.
+A server may use the redirect to request that the client
+"pin" itself to a particular server for the remainder of
+the current transaction.
+
+The URL listed in any redirect should be the base URL
+without any query args.  The client will automatically
+append "/backend.git-http/$service" as it makes each
+future request.
+
+If no "refs" line was received in the response, but
+a "redirect" was received, the client should retry
+its request at the new location before giving up.
+
 Service upload-pack
 -------------------
 
-- 
Shawn.

  reply	other threads:[~2008-08-26 17:27 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26  1:26 Git-aware HTTP transport Shawn O. Pearce
2008-08-26  2:34 ` H. Peter Anvin
2008-08-26  3:45   ` Shawn O. Pearce
2008-08-26  3:59     ` david
2008-08-26  4:15       ` H. Peter Anvin
2008-08-26  4:25         ` david
2008-08-26  4:42           ` H. Peter Anvin
2008-08-26  4:45           ` Imran M Yousuf
2008-08-26 17:01       ` Nicolas Pitre
2008-08-26 17:03         ` Shawn O. Pearce
2008-08-26  4:14     ` H. Peter Anvin
2008-08-26 14:58   ` Shawn O. Pearce
2008-08-26 16:14     ` Shawn O. Pearce
2008-08-26 16:33     ` H. Peter Anvin
2008-08-26 17:26       ` Shawn O. Pearce [this message]
2008-08-26 22:38         ` H. Peter Anvin
2008-08-27  2:51           ` Imran M Yousuf
2008-08-28  3:50           ` Shawn O. Pearce
2008-08-28  4:37             ` H. Peter Anvin
2008-08-28  4:42               ` Shawn O. Pearce
2008-08-28  4:58                 ` H. Peter Anvin
2008-08-28  6:40               ` Imran M Yousuf
2008-08-28  4:42             ` Junio C Hamano
2008-08-28 14:57               ` Shawn O. Pearce
2008-08-28 17:26                 ` david
2008-08-28 17:28                   ` Shawn O. Pearce
2008-08-28 17:37                     ` david
2008-08-28 17:38                       ` Daniel Stenberg
2008-08-28 17:43                       ` Shawn O. Pearce
2008-08-28 17:47                         ` H. Peter Anvin
2008-08-28 18:04                       ` Mike Hommey
2008-08-28 17:43                   ` H. Peter Anvin
2008-08-28 18:12                     ` david
2008-08-28 18:14                       ` H. Peter Anvin
2008-08-28 18:18                         ` david
2008-08-29  4:02                 ` Junio C Hamano
2008-08-29  5:11                   ` H. Peter Anvin
2008-08-29  6:50                     ` Junio C Hamano
2008-08-29 17:39                       ` Shawn O. Pearce
2008-08-29 19:55                         ` Nicolas Pitre
2008-09-01 16:05                         ` Tarmigan
2008-09-01 16:13                           ` Tarmigan
2008-09-02  6:06                           ` Shawn O. Pearce
2008-09-02  6:09                             ` H. Peter Anvin
2008-09-02  6:13                               ` Shawn O. Pearce
2008-09-02 18:20                             ` Tarmigan
2008-08-28 17:05               ` H. Peter Anvin
2008-08-28 17:10                 ` Shawn O. Pearce
2008-08-28 17:20                   ` H. Peter Anvin
2008-08-28 17:26                     ` Shawn O. Pearce
2008-08-28 17:44                       ` H. Peter Anvin
2008-08-28 17:46                         ` Shawn O. Pearce
2008-08-28 18:40                       ` Nicolas Pitre
2008-08-28 18:47                         ` H. Peter Anvin
2013-02-13  1:34 ` Git-aware HTTP transport docs H. Peter Anvin
2013-02-13  2:23   ` Scott Chacon
2013-02-13 15:29     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080826172648.GK26523@spearce.org \
    --to=spearce@spearce$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=hpa@zytor$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox