origin

package
v0.7.3-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package origin compares URLs by origin: scheme, host and port. A bearer credential is sent only to the origin that issued it, so two spellings of one origin must compare equal and nothing else may: not the same host over another scheme, where the credential would travel in clear, and not the same host on another port, which can be another service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Guard

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

Guard returns a copy of c that never carries an Authorization header across origins. net/http keeps that header on a redirect to the same host, or to a subdomain of it, whatever the scheme or the port, so a registry's answer pointing at http:// on its own host, at another port or at a sibling subdomain would take a bearer token with it. Guard compares every hop with the origin of the request the caller sent, so a hop back to that origin gets the header again and one away from it does not. A redirect policy c already has still decides whether the redirect is followed; with none, the default limit of ten applies. A nil c is http.DefaultClient.

func Host

func Host(host string) (string, bool)

Host is host as a request resolves it: lower-cased, without trailing dots, and a non-ASCII name in its ASCII (punycode) form, so that two spellings of one host compare equal. ok is false for a name that has no such form.

func Of

func Of(rawURL string) string

Of is rawURL's scheme, host and port, lower-cased, with the scheme's default port dropped; "" for a URL with no host or a host with no ASCII form.

func Same

func Same(a, b string) bool

Same reports whether a and b share an origin. A URL with no origin shares it with nothing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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