package proxy
import "cloud.google.com/go/httpreplay/internal/proxy"
The proxy package provides a record/replay HTTP proxy. It is designed to support both an in-memory API (cloud.google.com/go/httpreplay) and a standalone server (cloud.google.com/go/httpreplay/cmd/httpr).
Index ¶
- Constants
- Variables
- type Entry
- type Log
- type Logger
- func NewLogger() *Logger
- func (l *Logger) Extract() *Log
- func (l *Logger) ModifyRequest(req *http.Request) error
- func (l *Logger) ModifyResponse(res *http.Response) error
- type Proxy
- func ForRecording(filename string, port int) (*Proxy, error)
- func ForReplaying(filename string, port int) (*Proxy, error)
- func (p *Proxy) Close() error
- func (p *Proxy) IgnoreHeader(h string)
- func (p *Proxy) Transport() *http.Transport
- type Request
- type Response
Constants ¶
const LogVersion = "0.1"
Variables ¶
var DebugHeaders = false
DebugHeaders helps to determine whether a header should be ignored. When true, if requests have the same method, URL and body but differ in a header, the first mismatched header is logged.
Types ¶
type Entry ¶
An Entry single request-response pair.
type Log ¶
type Log struct { Initial []byte // initial data for replay Version string // version of this log format Entries []*Entry }
A Log is a record of HTTP interactions, suitable for replay. It can be serialized to JSON.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger maintains a request-response log.
func NewLogger ¶
func NewLogger() *Logger
NewLogger creates a new logger.
func (*Logger) Extract ¶
Extract returns the Log and removes it. The Logger is not usable after this call.
func (*Logger) ModifyRequest ¶
ModifyRequest logs requests.
func (*Logger) ModifyResponse ¶
ModifyResponse logs responses.
type Proxy ¶
type Proxy struct { // The certificate that the proxy uses to participate in TLS. CACert *x509.Certificate // The URL of the proxy. URL *url.URL // Initial state of the client. Initial []byte // contains filtered or unexported fields }
A Proxy is an HTTP proxy that supports recording or replaying requests.
func ForRecording ¶
ForRecording returns a Proxy configured to record.
func ForReplaying ¶
ForReplaying returns a Proxy configured to replay.
func (*Proxy) Close ¶
Close closes the proxy. If the proxy is recording, it also writes the log.
func (*Proxy) IgnoreHeader ¶
IgnoreHeader will cause h to be ignored during matching on replay.
func (*Proxy) Transport ¶
Transport returns an http.Transport for clients who want to talk to the proxy.
type Request ¶
type Request struct { Method string // http.Request.Method URL string // http.Request.URL, as a string Proto string // http.Request.Proto Header http.Header // http.Request.Header Body []byte // http.Request.Body, read to completion Trailer http.Header `json:",omitempty"` // http.Request.Trailer }
A Request represents an http.Request in the log.
type Response ¶
type Response struct { StatusCode int // http.Response.StatusCode Proto string // http.Response.Proto ProtoMajor int // http.Response.ProtoMajor ProtoMinor int // http.Response.ProtoMinor Header http.Header // http.Response.Header Body []byte // http.Response.Body, read to completion Trailer http.Header `json:",omitempty"` // http.Response.Trailer }
A Response represents an http.Response in the log.
Source Files ¶
debug.go log.go record.go replay.go
- Version
- v0.27.0
- Published
- Sep 4, 2018
- Platform
- js/wasm
- Imports
- 24 packages
- Last checked
- 9 minutes ago –
Tools for package owners.