Help us shape the future of Go! Take the 2026 Go Developer Survey

httpclient

package
v0.130.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package httpclient contains helpers for HTTP clients that send credentials.

Index

Constants

This section is empty.

Variables

View Source
var ErrCrossOriginRedirect = errors.New("redirect to a different origin was blocked")

ErrCrossOriginRedirect is returned when a request with credentials is redirected to another origin.

Functions

func Origin

func Origin(u *url.URL) string

Origin returns scheme://host:port for a URL, with the default port filled in. It contains no user info, path or query, so it is safe to log.

func SameOrigin

func SameOrigin(a, b *url.URL) bool

SameOrigin reports whether two URLs have the same scheme, host and effective port.

func SameOriginRedirects

func SameOriginRedirects(req *http.Request, via []*http.Request) error

SameOriginRedirects is an http.Client CheckRedirect function for requests that carry credentials. It follows a redirect only when scheme, host and port stay the same as in the first request. net/http still forwards the Authorization header to subdomains, other ports and from https to http. This function blocks those redirects before a request reaches the new target.

Types

This section is empty.

Jump to

Keyboard shortcuts

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