noredirect

package
v0.141.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package noredirect is THE rule for an outbound HTTP client that carries a credential: it never follows a redirect.

Go's net/http re-sends a request's Authorization header on a redirect to the same hostname (any port, any scheme) and to its subdomains, and every other header (a WebSocket subprotocol carrying a ticket, say) to ANY host. So a server that answers with a 3xx — a misconfigured proxy, a login page, a compromised upstream — would be handed the credential at the Location it names. A client built here refuses the redirect before that second request is made, and says where it was being sent.

One rule, one place: every credential-bearing client the mirror binary makes is built with Client (a structural test in cmd/muster-mirror fails a new http.Client literal that is not).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(req *http.Request, _ []*http.Request) error

Check is an http.Client CheckRedirect that refuses every redirect with an *Error naming the Location's host. net/http calls it BEFORE the redirected request is sent, so the Location never receives a request.

func Client

func Client(c *http.Client) *http.Client

Client returns a copy of c that refuses every redirect (Check); a nil c is a new zero client. The copy shares c's Transport, Jar and Timeout; c itself is not modified.

Types

type Error

type Error struct {
	// Host is the refused Location's host (and port, when it names one).
	Host string
}

Error is a redirect a client built by Client refused to follow.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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