httpspeed

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package httpspeed implements core.SpeedTester against Cloudflare's public speed-test endpoint. No API key or self-hosted server required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tester

type Tester struct {
	Client  *http.Client
	BaseURL string // overridable for tests; defaults to Cloudflare in New().
}

Tester times HTTP transfers against a speed-test server.

func New

func New() Tester

func (Tester) Colo added in v0.2.0

func (t Tester) Colo(ctx context.Context) string

Colo returns the three-letter code of the Cloudflare datacenter that answered (e.g. "GRU" for São Paulo), or "" if it can't be determined. speed.cloudflare.com is anycast: the same URL always routes to whichever of Cloudflare's ~300 edges is closest, so this exists to make that concrete instead of asserting it — hits Cloudflare's public trace endpoint, which every Cloudflare-proxied hostname serves.

func (Tester) Download

func (t Tester) Download(ctx context.Context, size int64) (time.Duration, error)

Download fetches size bytes and reports how long the transfer took.

func (Tester) Upload

func (t Tester) Upload(ctx context.Context, size int64) (time.Duration, error)

Upload sends size bytes and reports how long the transfer took.

Jump to

Keyboard shortcuts

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