proxytarget

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package proxytarget keeps a plain-HTTP request's destination intact when it is forwarded through an HTTP proxy (Burp, --proxy http://…, HTTP_PROXY).

A forward proxy routes a plain-HTTP request by the absolute-form request target ("GET http://host:port/path HTTP/1.1"), and net/http writes that target from req.Host, not req.URL.Host (Request.write in net/http). When the Host header deliberately differs from the URL being fetched — a Host-header-injection probe, a fuzzed Host, a vhost probe, a replay retargeted at another environment, or a Host captured without the port — the proxy is told to fetch the Host header's authority and forwards the request there instead of to the target.

Transport fixes that one case: for a plain-HTTP request sent through an HTTP or HTTPS proxy whose Host differs from req.URL.Host, it sends the absolute form built from req.URL (scheme://host:port/path) while the Host header still carries the override. Every other request passes through unchanged: direct connections, SOCKS proxies (which dial req.URL's host:port), and https targets (tunnelled with CONNECT to req.URL's host:port).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(rt http.RoundTripper) (*http.Transport, bool)

Base returns the *http.Transport behind rt: rt itself when it is one, the embedded transport when rt is a *Transport, else nil and false. Callers that adjust a client's transport after construction use it so wrapping does not hide the transport from them.

Types

type Transport

type Transport struct {
	*http.Transport
}

Transport is an *http.Transport whose RoundTrip keeps req.URL's authority in the request target sent to an HTTP proxy. The embedded transport carries all configuration (Proxy, TLS, dialers, pools); its other methods, such as CloseIdleConnections, are promoted unchanged. Safe for concurrent use.

func Wrap

func Wrap(t *http.Transport) *Transport

Wrap returns t behind the proxy-target fix. A nil t wraps a zero-value *http.Transport.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

Directories

Path Synopsis
Package proxytest provides a recording forward HTTP proxy for tests that assert what a client puts on the wire to a proxy.
Package proxytest provides a recording forward HTTP proxy for tests that assert what a client puts on the wire to a proxy.

Jump to

Keyboard shortcuts

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