httpclient

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package httpclient is the one place mcpmu builds outbound HTTP clients and reads response bodies. Both the MCP transport and the OAuth flows go through it so every upstream request gets the same redirect policy and every body read is bounded.

Index

Constants

View Source
const (
	// MaxRedirects is how many hops a client follows before giving up.
	MaxRedirects = 3

	// DefaultConnectTimeout bounds dialing, the TLS handshake and the wait for
	// response headers. It is deliberately not a whole-request deadline: SSE
	// bodies stay open indefinitely.
	DefaultConnectTimeout = 30 * time.Second
)

Variables

View Source
var ErrBodyTooLarge = errors.New("response body too large")

ErrBodyTooLarge is returned by ReadBody when a response body exceeds the caller's limit.

View Source
var ErrCrossOriginRedirect = errors.New("refusing cross-origin redirect")

ErrCrossOriginRedirect is the reason a client refuses to follow a redirect to a different scheme or host.

Functions

func New

func New(base *http.Client) *http.Client

New returns a client derived from base (http.DefaultClient when nil) that refuses cross-origin redirects and never applies http.Client.Timeout.

Go replays custom headers — Authorization, Mcp-Session-Id, CF-Access-* — on every hop it follows, so a same-origin-only policy is what keeps an upstream from bouncing our credentials to a third party. Per-request deadlines come from the request context; connection-level timeouts from the transport.

func ReadBody

func ReadBody(resp *http.Response, limit int64) ([]byte, error)

ReadBody reads resp.Body up to limit bytes and closes it. A body larger than limit yields ErrBodyTooLarge (wrapped), never a silently truncated slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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