securehttp

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package securehttp provides outbound HTTP clients for remote MCP and OAuth services.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidURL reports a URL that cannot be used as a remote HTTP destination.
	ErrInvalidURL = outboundpolicy.ErrInvalidURL
	// ErrInsecureTransport reports HTTP used for a non-loopback destination.
	ErrInsecureTransport = outboundpolicy.ErrInsecureTransport
	// ErrBlockedDestination reports an address outside the configured destination policy.
	ErrBlockedDestination = outboundpolicy.ErrBlockedDestination
	// ErrTooManyRedirects reports a redirect chain beyond the client's configured limit.
	ErrTooManyRedirects = errors.New("securehttp: too many redirects")
	// ErrResponseBodyTooLarge reports a response body that exceeds the configured limit.
	ErrResponseBodyTooLarge = errors.New("securehttp: response body exceeds the configured limit")
)

Functions

func RedactError

func RedactError(err error) error

RedactError removes request URLs and credentials from errors returned by APIs that require the underlying HTTP client.

func ValidateURL

func ValidateURL(raw string) error

ValidateURL checks a URL against the default public-only destination policy.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an outbound HTTP client whose requests are checked against the MCP network policy.

func NewClient

func NewClient(clientOptions ...Option) *Client

NewClient constructs a secure, proxy-free HTTP client.

func (*Client) Do

func (c *Client) Do(request *http.Request) (*http.Response, error)

Do executes a request and returns errors without request URLs or credentials.

func (*Client) HTTPClient

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

HTTPClient returns the underlying client for APIs that require *http.Client. Call Do directly or pass API errors through RedactError at the boundary.

func (*Client) ValidateURL

func (c *Client) ValidateURL(raw string) error

ValidateURL checks a URL against this client's static destination policy. DNS answers are revalidated immediately before every connection.

type Option

type Option func(*options)

Option configures a Client.

func WithAllowLoopback

func WithAllowLoopback(allow bool) Option

WithAllowLoopback permits explicit loopback destinations, including HTTP. It is disabled by default so catalog destinations remain public-only.

func WithMaxResponseBodyBytes

func WithMaxResponseBodyBytes(size int64) Option

WithMaxResponseBodyBytes configures the maximum readable response body. A non-positive value keeps the default.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures the end-to-end timeout. A non-positive value keeps the default.

Jump to

Keyboard shortcuts

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