netdiag

package
v0.0.0-...-39278d5 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// Raw phase timestamps (zero if phase not reached).
	Start               time.Time
	DNSStart, DNSDone   time.Time
	ConnStart, ConnDone time.Time
	TLSStart, TLSDone   time.Time
	FirstByte           time.Time
	End                 time.Time

	// Outcome
	Method     string
	URL        string
	Status     string
	Proto      string
	Err        error
	RespHeader http.Header
	TLSState   *tls.ConnectionState
	// Whether the underlying connection was reused.
	ReusedConn bool
}

Result holds timing phases & response metadata for one HTTP request.

func Diagnose

func Diagnose(ctx context.Context, rawURL string, method string, client *http.Client) (*Result, error)

Diagnose executes a single HTTP request (default HEAD) and returns a populated Result. method="" defaults to HEAD; pass GET if you want body download to influence Total. ctx controls total timeout / cancellation *outside* the per-request http.Client timeout you might add.

func (*Result) ConnectDuration

func (r *Result) ConnectDuration() time.Duration

func (*Result) DNSDuration

func (r *Result) DNSDuration() time.Duration

Durations (computed lazily so callers can format however they want)

func (*Result) StringVerbose

func (r *Result) StringVerbose() string

func (*Result) TLSDuration

func (r *Result) TLSDuration() time.Duration

func (*Result) TTFB

func (r *Result) TTFB() time.Duration

func (*Result) Total

func (r *Result) Total() time.Duration

func (*Result) WriteTimings

func (r *Result) WriteTimings(w io.Writer)

WriteTimings writes only the curl -w style timing summary.

func (*Result) WriteTo

func (r *Result) WriteTo(w io.Writer) (int64, error)

Implement io.WriterTo so callers can: io.Copy(os.Stdout, res)

func (*Result) WriteVerbose

func (r *Result) WriteVerbose(w io.Writer) error

WriteVerbose writes a curl -v style transcript (phases + headers + timings) to w.

Jump to

Keyboard shortcuts

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