module documentation

HTTP server for dulwich that implements the git smart HTTP protocol.

Class ChunkReader Reader for chunked transfer encoding streams.
Class GunzipFilter WSGI middleware that unzips gzip-encoded requests before passing on to the underlying application.
Class HandlerConstructor Protocol for handler constructors.
Class HTTPGitApplication Class encapsulating the state of a git WSGI application.
Class HTTPGitRequest Class encapsulating the state of a single git HTTP request.
Class LimitedInputFilter WSGI middleware that limits the input length of a request to that specified in Content-Length.
Class ServerHandlerLogger ServerHandler that uses dulwich's logger for logging exceptions.
Class WSGIRequestHandlerLogger WSGIRequestHandler that uses dulwich's logger for logging exceptions.
Class WSGIServerLogger WSGIServer that uses dulwich's logger for error handling.
Function cache_forever_headers Generate headers for caching forever.
Function date_time_string Convert a timestamp to an HTTP date string.
Function get_idx_file Send a git pack index file.
Function get_info_packs Send git info/packs file listing available packs.
Function get_info_refs Send git info/refs for discovery.
Function get_loose_object Send a loose git object.
Function get_pack_file Send a git pack file.
Function get_repo Get a Repo instance for the given backend and URL regex match.
Function get_text_file Send a plain text file from the repository.
Function handle_service_request Handle a git service request (upload-pack or receive-pack).
Function main Entry point for starting an HTTP git server.
Function make_wsgi_chain Factory function to create an instance of HTTPGitApplication.
Function send_file Send a file-like object to the request output.
Function url_prefix Extract the URL prefix from a regex match.
Constant HTTP_ERROR Undocumented
Constant HTTP_FORBIDDEN Undocumented
Constant HTTP_NOT_FOUND Undocumented
Constant HTTP_OK Undocumented
Constant NO_CACHE_HEADERS Undocumented
Variable logger Undocumented
Class _LengthLimitedFile Wrapper class to limit the length of reads from a file-like object.
Function _chunk_iter Undocumented
Function _url_to_path Undocumented
def cache_forever_headers(now: float | None = None) -> list[tuple[str, str]]:

Generate headers for caching forever.

Parameters
now:float | NoneTimestamp to use as base (defaults to current time)
Returns
list[tuple[str, str]]List of (header_name, header_value) tuples for caching forever
def date_time_string(timestamp: float | None = None) -> str:

Convert a timestamp to an HTTP date string.

Parameters
timestamp:float | NoneUnix timestamp to convert (defaults to current time)
Returns
strHTTP date string in RFC 1123 format
def get_idx_file(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send a git pack index file.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the requested index file
Returns
Iterator[bytes]Iterator yielding index file contents as bytes
def get_info_packs(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send git info/packs file listing available packs.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the info/packs request
Returns
Iterator[bytes]Iterator yielding pack listing as bytes
def get_info_refs(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send git info/refs for discovery.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the info/refs request
Returns
Iterator[bytes]Iterator yielding refs advertisement or info/refs contents
def get_loose_object(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send a loose git object.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match containing object path segments
Returns
Iterator[bytes]Iterator yielding object contents as bytes
def get_pack_file(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send a git pack file.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the requested pack file
Returns
Iterator[bytes]Iterator yielding pack file contents as bytes
def get_repo(backend: Backend, mat: re.Match[str]) -> BaseRepo:

Get a Repo instance for the given backend and URL regex match.

def get_text_file(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Send a plain text file from the repository.

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the requested path
Returns
Iterator[bytes]Iterator yielding file contents as bytes
def handle_service_request(req: HTTPGitRequest, backend: Backend, mat: re.Match[str]) -> Iterator[bytes]:

Handle a git service request (upload-pack or receive-pack).

Parameters
req:HTTPGitRequestThe HTTP request object
backend:BackendThe git backend
mat:re.Match[str]The regex match for the service request
Returns
Iterator[bytes]Iterator yielding service response as bytes
def main(argv: list[str] = sys.argv):

Entry point for starting an HTTP git server.

def make_wsgi_chain(backend: Backend, dumb: bool = False, handlers: dict[bytes, Callable[..., Any]] | None = None, fallback_app: WSGIApplication | None = None) -> WSGIApplication:

Factory function to create an instance of HTTPGitApplication.

Correctly wrapped with needed middleware.

def send_file(req: HTTPGitRequest, f: BinaryIO | None, content_type: str) -> Iterator[bytes]:

Send a file-like object to the request output.

Returns: Iterator over the contents of the file, as chunks.

Parameters
req:HTTPGitRequestThe HTTPGitRequest object to send output to.
f:BinaryIO | NoneAn open file-like object to send; will be closed.
content_type:strThe MIME type for the file.
Returns
Iterator[bytes]Undocumented
def url_prefix(mat: re.Match[str]) -> str:

Extract the URL prefix from a regex match.

Returns: The URL prefix, defined as the text before the match in the
original string. Normalized to start with one leading slash and end with zero.
Parameters
mat:re.Match[str]A regex match object.
Returns
strUndocumented
HTTP_ERROR: str =

Undocumented

Value
'500 Internal Server Error'
HTTP_FORBIDDEN: str =

Undocumented

Value
'403 Forbidden'
HTTP_NOT_FOUND: str =

Undocumented

Value
'404 Not Found'
HTTP_OK: str =

Undocumented

Value
'200 OK'
NO_CACHE_HEADERS: list =

Undocumented

Value
[('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT'),
 ('Pragma', 'no-cache'),
 ('Cache-Control', 'no-cache, max-age=0, must-revalidate')]
logger =

Undocumented

def _chunk_iter(f: BinaryIO) -> Iterator[bytes]:

Undocumented

def _url_to_path(url: str) -> str:

Undocumented