redirecttest

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 5 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 redirecttest checks, from tests, that an HTTP client keeps credential headers on their origin when a server redirects to another host.

Index

Constants

View Source
const ProbeHeader = "X-Goog-Api-Key"

ProbeHeader is the credential header the checks send. http.Client itself copies it to any host, so only a credential redirect policy keeps it off.

Variables

This section is empty.

Functions

func CallerClient

func CallerClient() (*http.Client, *atomic.Int32)

CallerClient returns a client like one a caller passes in, with its own CheckRedirect that counts the hops it sees and lets them through.

func SendThroughCrossHostRedirect

func SendThroughCrossHostRedirect(t *testing.T, client *http.Client) (atOrigin, atTarget http.Header)

SendThroughCrossHostRedirect sends a request carrying ProbeHeader through client to an origin that answers with a 307 to another host. It returns the headers the origin and the other host received.

Types

type Result

type Result struct {
	// AtOrigin and AtTarget are the ProbeHeader values the origin and the
	// other host received through the client under test.
	AtOrigin, AtTarget string
	// CallerHops counts the hops the caller's own CheckRedirect saw.
	CallerHops int32
	// CallerDirect is the ProbeHeader value the other host received when the
	// request went through the caller's own client: still "secret" if the
	// caller's client was not modified.
	CallerDirect string
}

Result is what Probe saw.

func Probe

func Probe(t *testing.T, used, caller *http.Client, hops *atomic.Int32) Result

Probe sends ProbeHeader through used (the client a provider built from caller) and then through caller itself, each to an origin that redirects to another host, and reports what each host received.

Jump to

Keyboard shortcuts

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