gitprotocol-http(5)
gitprotocol-http(5) Manual Page NAME gitprotocol-http - Git HTTP-based protocols SYNOPSIS <over-the-wire-protocol> DESCRIPTION Git supports two HTTP based transfer protocols. A "dumb" protocol which requires only a standard HTTP server on the server end of the connection, and a "smart" protocol which requires a Git aware CGI (or server module). This document describes both protocols. As a design feature smart clients can automatically upgrade "dumb" protocol URLs to smart URLs.
This permits all users to have the same published URL, and the peers automatically select the most efficient transport available to them. URL Format URLs for Git repositories accessed by HTTP use the standard HTTP URL syntax documented by RFC 1738, so they are of the form: http://<host>:<port>/<path>?<searchpart> Within this documentation the placeholder $GIT_URL will stand for the http:// repository URL entered by the end-user.
Servers SHOULD handle all requests to locations matching $GIT_URL , as both the "smart" and "dumb" HTTP protocols used by Git operate by appending additional path components onto the end of the user supplied $GIT_URL string. An example of a dumb client requesting a loose object: $GIT_URL: http://example.com:8080/git/repo.git URL request: http://example.com:8080/git/repo.git/objects/d0/49f6c27a2244e12041955e262a404c7faba355 An example of a smart request to a catch-all gateway: $GIT_URL: http://example.com/daemon.cgi?svc=git&q= URL request: http://example.com/daemon.cgi?svc=git&q=/info/refs&service=git-receive-pack An example of a request to a submodule: $GIT_URL: http://example.com/git/repo.git/path/submodule.git URL request: http://example.com/git/repo.git/path/submodule.git/info/refs Clients MUST strip a trailing / , if present, from the user supplied $GIT_URL string to prevent empty path tokens ( // ) from appearing in any URL sent to a server.
Compatible clients MUST expand $GIT_URL/info/refs as foo/info/refs and not foo//info/refs . Authentication Standard HTTP authentication is used if authentication is required to access a repository, and MAY be configured and enforced by the HTTP server software. Because Git repositories are accessed by standard path components server administrators MAY use directory based permissions within their HTTP server to control repository access.
Clients SHOULD support Basic authentication as described by RFC 2617. Servers SHOULD support Basic authentication by relying upon the HTTP server placed in front of the Git server software. Servers SHOULD NOT require HTTP cookies for the purposes of authentication or access control. Clients and servers MAY support other common forms of HTTP based authentication, such as Digest authentication. SSL Clients and servers SHOULD support SSL, particularly to protect passwords when relying on Basic HTTP authentication.
Session State The Git over HTTP protocol (much like HTTP itself) is stateless from the perspective of the HTTP server side. All state MUST be retained and managed by the client process. This permits simple round-robin load-balancing on the server side, without needing to worry about state management. Clients MUST NOT require state management on the server side in order to function correctly. Servers MUST NOT require HTTP cookies in order to function correctly.
Clients MAY store and forward HTTP cookies during request processing as described by RFC 2616 (HTTP/1.1). Servers SHOULD ignore any cookies sent by a client. General Request Processing Except where noted, all standard HTTP behavior SHOULD be assumed by both client and server. This includes (but is not necessarily limited to): If there is no repository at $GIT_URL , or the resource pointed to by a location matching $GIT_URL does not exist, the server MUST NOT respond with 200 OK response.
A server SHOULD respond with 404 Not Found , 410 Gone , or any other suitable HTTP status code which does not imply the resource exists as requested. If there is a repository at $GIT_URL , but access is not currently permitted, the server MUST respond with the 403 Forbidden HTTP status code. Servers SHOULD support both HTTP 1.0 and HTTP 1.1. Servers SHOULD support chunked encoding for both request and response bodies.
Clients SHOULD support both HTTP 1.0 and HTTP 1.1. Clients SHOULD support chunked encoding for both request and response bodies. Servers MAY return ETag and/or Last-Modified headers. Clients MAY revalidate cached entities by including If-Modified-Since and/or If-None-Match request headers. Servers MAY return 304 Not Modified if the relevant headers appear in the request and the entity has not changed. Clients MUST treat 304 Not Modified identical to 200 OK by reusing the cached entity.
Clients MAY reuse a cached entity without revalidation if the Cache-Control and/or Expires header permits caching. Clients and servers MUST follow RFC 2616 for cache controls. Discovering References All HTTP clients MUST begin either a fetch or a push exchange by discovering the references available on the remote repository. Dumb Clients HTTP clients that only support the "dumb" protocol MUST discover references by making a request for the special info/refs file of the repository.
Dumb HTTP clients MUST make a GET request to $GIT_URL/info/refs , without any search/query parameters. C: GET $GIT_URL/info/refs HTTP/1.0 S: 200 OK S: S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{} The Content-Type of the returned info/refs entity SHOULD be text/plain ; charset=utf-8 , but MAY be any content type.
Clients MUST NOT attempt to validate the returned Content-Type. Dumb servers MUST NOT return a return type starting with application/x-git- . Cache-Control headers MAY be returned to disable caching of the returned entity. When examining the response clients SHOULD only examine the HTTP status code. Valid responses are 200 OK , or 304 Not Modified . The returned content is a UNIX formatted text file describing each ref and its known value.
The file SHOULD be sorted by name according to the C locale ordering. The file SHOULD NOT include the default ref named HEAD . info_refs = *( ref_record ) ref_record = any_ref / peeled_ref any_ref = obj-id HTAB refname LF peeled_ref = obj-id HTAB refname LF obj-id HTAB refname "^{}" LF Smart Clients HTTP clients that support the "smart" protocol (or both the "smart" and "dumb" protocols) MUST discover references by making a parameterized request for the info/refs file of the repository.
The request MUST contain exactly one query parameter, service=$servicename , where $servicename MUST be the service name the client wishes to contact to complete the operation. The request MUST NOT contain additional query parameters. C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0 dumb server reply: S: 200 OK S: S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{} smart server reply: S: 200 OK S: Content-Type: application/x-git-upload-pack-advertisement S: Cache-Control: no-cache S: S: 001e# service=git-upload-pack\n S: 0000 S: 004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0multi_ack\n S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n S: 0000 The client may send Extra Parameters (see gitprotocol-pack(5) ) as a colon-separated string in the Git-Protocol HTTP header.
Uses the --http-backend-info-refs option to git-upload-pack(1) . Dumb Server Response Dumb servers MUST respond with the dumb server reply format. See the prior section under dumb clients for a more detailed descr
The rest of this page is on the live site.