httputil

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DialTimeout bounds establishing the TCP connection.
	DialTimeout = 10 * time.Second
	// TLSHandshakeTimeout bounds completing the TLS handshake.
	TLSHandshakeTimeout = 10 * time.Second
	// ResponseHeaderTimeout bounds the wait, after the request is written, for
	// the server to begin sending response headers. This is the only timeout
	// that protects against a server which accepts the connection but then goes
	// silent — the originally reported #1018 symptom; DialTimeout/
	// TLSHandshakeTimeout do not, because the connection already succeeded.
	//
	// The value must clear Gitea's legitimate synchronous pre-response work.
	// Profiling a self-hosted Gitea 1.24.6 (on hardware slower than gitea.com)
	// showed creating a pull request that triggers conflict detection across
	// ~1500 changed files takes ~10s before the first byte (3 runs: 10.06 /
	// 10.08 / 10.24s); clean-diff PR creation was ~1s and large attachment
	// uploads ~9ms. 120s is ~12x that measured worst case, leaving generous
	// headroom for larger repos and busier servers while still failing in two
	// minutes instead of hanging forever.
	ResponseHeaderTimeout = 120 * time.Second
)

Timeout values applied to every Gitea API request. These are deliberately connection-establishment and time-to-first-response-byte timeouts, NOT an overall request deadline: a large release-attachment upload can legitimately run for minutes, and as long as bytes keep flowing none of these fire. They only trip when a server accepts the connection but never (or far too slowly) starts responding — the "hangs forever" case from a stalled or unresponsive server (issue #1018).

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

UserAgent returns the standard User-Agent string for tea.

func WrapTransport

func WrapTransport(tlsConfig *tls.Config) http.RoundTripper

WrapTransport returns tea's standard HTTP transport: an *http.Transport preset with tea's connection / response-header timeouts (see timeoutTransport) and decorated to add the User-Agent header on every request. The supplied tlsConfig is attached as-is (nil is fine); callers use it for insecure / skip-verify logins. This is the single entry point for building a tea HTTP client transport, so the timeouts can't be accidentally omitted.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL