Open-Source Wikis

/

MinIO

/

Packages

/

http and net

minio/minio

http and net

The HTTP server, transport defaults, and helpers that sit between the Go standard library and cmd/.

internal/http

The customised HTTP server MinIO listens on. Highlights:

  • Server wraps net/http.Server with sensible idle/read/write timeouts (DefaultIdleTimeout, DefaultReadHeaderTimeout).
  • Connection-level rate limiting (MINIO_API_REQUESTS_MAX and MINIO_API_REQUESTS_DEADLINE).
  • Request-size enforcement before bodies hit the application.
  • Custom Listener that supports SO_REUSEPORT-style multi-listener mode.
  • NewHTTPClient returns a transport tuned for inter-cluster traffic (large connection pools, custom DNS cache).

Used by cmd/server-main.go for the public HTTP listener and by internal/rest for the per-peer client.

internal/handlers

Shared HTTP middleware used by the API router: RealIP, RequestID, OPTIONS handling, body-size limits. They are simple enough to be reusable across routers.

internal/mcontext

A wrapper around context.Context that carries request-scoped metadata across middleware boundaries: request ID, trace flags, host, user agent. Most handlers read this context to log structured data.

internal/net

Small helpers that don't fit in internal/http:

  • IPv4/IPv6 helpers for endpoint parsing.
  • Reverse-DNS lookups guarded by a cache.

internal/deadlineconn

A net.Conn wrapper that enforces both a read and a write deadline that resets on activity. Used to bound how long an erasure-write can stall on a slow peer.

internal/ioutil

I/O helpers used by drives and replication:

  • LimitedReader with size-aware errors.
  • Copy with cancellation context.
  • WriteOnCloser patterns for atomic writes.
  • Aligned reads/writes for DirectIO drives (when supported by internal/disk).

internal/handlers and request lifecycle

The router (cmd/api-router.go) chains generic middleware → auth → handler. The middleware in internal/handlers/ is the boring-but-essential layer that makes the chain consistent across S3, admin, KMS, and STS routes.

Integration points

  • cmd/server-main.go constructs the internal/http.Server.
  • internal/rest and cmd/storage-rest-client.go use internal/http.NewHTTPClient.
  • Most packages don't depend on internal/http directly; they go through cmd/ or internal/rest.

Entry points for modification

  • Tune defaults. internal/http/const.go-style constants are read by the server bootstrap.
  • New middleware. Add it to internal/handlers/ and wire from cmd/routers.go.
  • New transport behaviour. Don't reach for net/http.Transport directly; extend NewHTTPClient so the change applies cluster-wide.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

http and net – MinIO wiki | Factory