Movatterモバイル変換


[0]ホーム

URL:


proxy

package
v0.123.0Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License:Apache-2.0Imports:25Imported by:0

Details

Repository

github.com/googleapis/google-cloud-go

Links

Documentation

Overview

Package proxy provides a record/replay HTTP proxy. It is designed to supportboth an in-memory API (cloud.google.com/go/httpreplay) and a standalone server(cloud.google.com/go/httpreplay/cmd/httpr).

Index

Constants

View Source
const LogVersion = "0.2"

LogVersion is the current version of the log format. It can be used tosupport changes to the format over time, so newer code can read older files.

Variables

View Source
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 differin a header, the first mismatched header is logged.

Functions

This section is empty.

Types

typeConverteradded inv0.35.0

type Converter struct {// These all apply to both headers and trailers.ClearHeaders          []tRegexp// replace matching headers with "CLEARED"RemoveRequestHeaders  []tRegexp// remove matching headers in requestsRemoveResponseHeaders []tRegexp// remove matching headers in responsesClearParams           []tRegexp// replace matching query params with "CLEARED"RemoveParams          []tRegexp// remove matching query params}

A Converter converts HTTP requests and responses to the Request and Response typesof this package, while removing or redacting information.

typeEntryadded inv0.25.0

type Entry struct {IDstring// unique IDRequest  *RequestResponse *Response}

An Entry single request-response pair.

typeLogadded inv0.25.0

type Log struct {Initial   []byte// initial data for replayVersionstring// version of this log formatConverter *ConverterEntries   []*Entry}

A Log is a record of HTTP interactions, suitable for replay. It can be serialized to JSON.

typeLoggeradded inv0.25.0

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

A Logger maintains a request-response log.

func (*Logger)Extractadded inv0.25.0

func (l *Logger) Extract() *Log

Extract returns the Log and removes it. The Logger is not usableafter this call.

func (*Logger)ModifyRequestadded inv0.25.0

func (l *Logger) ModifyRequest(req *http.Request)error

ModifyRequest logs requests.

func (*Logger)ModifyResponseadded inv0.25.0

func (l *Logger) ModifyResponse(res *http.Response)error

ModifyResponse logs responses.

typeProxy

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.

funcForRecording

func ForRecording(filenamestring, portint) (*Proxy,error)

ForRecording returns a Proxy configured to record.

funcForReplaying

func ForReplaying(filenamestring, portint) (*Proxy,error)

ForReplaying returns a Proxy configured to replay.

func (*Proxy)ClearHeadersadded inv0.35.0

func (p *Proxy) ClearHeaders(patterns []string)

ClearHeaders will replace matching headers with CLEARED.

This only needs to be called during recording; the patterns will be saved to thelog for replay.

func (*Proxy)ClearQueryParamsadded inv0.35.0

func (p *Proxy) ClearQueryParams(patterns []string)

ClearQueryParams will replace matching query params in the request URL with CLEARED.

This only needs to be called during recording; the patterns will be saved to thelog for replay.

func (*Proxy)Close

func (p *Proxy) Close()error

Close closes the proxy. If the proxy is recording, it also writes the log.

func (*Proxy)IgnoreHeaderadded inv0.25.0

func (p *Proxy) IgnoreHeader(hstring)

IgnoreHeader will cause h to be ignored during matching on replay.Deprecated: use RemoveRequestHeaders instead.

func (*Proxy)RemoveQueryParamsadded inv0.35.0

func (p *Proxy) RemoveQueryParams(patterns []string)

RemoveQueryParams will remove query parameters matching patterns from the requestURL before logging, and skip matching them. Pattern is taken literally except for*, which matches any sequence of characters.

This only needs to be called during recording; the patterns will be saved to thelog for replay.

func (*Proxy)RemoveRequestHeadersadded inv0.35.0

func (p *Proxy) RemoveRequestHeaders(patterns []string)

RemoveRequestHeaders will remove request headers matching patterns from the log,and skip matching them. Pattern is taken literally except for *, which matches anysequence of characters.

This only needs to be called during recording; the patterns will be saved to thelog for replay.

func (*Proxy)Transport

func (p *Proxy) Transport() *http.Transport

Transport returns an http.Transport for clients who want to talk to the proxy.

typeRequestadded inv0.25.0

type Request struct {Methodstring// http.Request.MethodURLstring// http.Request.URL, as a stringHeaderhttp.Header// http.Request.Header// We need to understand multipart bodies because the boundaries are// generated randomly, so we can't just compare the entire bodies for equality.MediaTypestring// the media type part of the Content-Type headerBodyParts [][]byte// http.Request.Body, read to completion and split for multipartTrailerhttp.Header `json:",omitempty"`// http.Request.Trailer}

A Request represents an http.Request in the log.

typeResponseadded inv0.25.0

type Response struct {StatusCodeint// http.Response.StatusCodeProtostring// http.Response.ProtoProtoMajorint// http.Response.ProtoMajorProtoMinorint// http.Response.ProtoMinorHeaderhttp.Header// http.Response.HeaderBody       []byte// http.Response.Body, read to completionTrailerhttp.Header `json:",omitempty"`// http.Response.Trailer}

A Response represents an http.Response in the log.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp