httpclient

package
v0.23.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(fs FileSystem) *Client

func (*Client) BuildHTTPRequest added in v0.19.2

func (c *Client) BuildHTTPRequest(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (*http.Request, Options, []byte, error)

BuildHTTPRequest prepares the request with expansions and returns the body bytes for reuse.

func (*Client) CompleteWebSocket added in v0.5.0

func (c *Client) CompleteWebSocket(
	ctx context.Context,
	handle *WebSocketHandle,
	req *restfile.Request,
	opts Options,
) (*Response, error)

func (*Client) Execute

func (c *Client) Execute(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (resp *Response, err error)

Wraps the HTTP roundtrip with telemetry spans and network tracing. Trace session hooks into http.Client's transport to capture timing info, while the defer ensures we always report metrics even on failure.

func (*Client) ExecuteSSE added in v0.5.0

func (c *Client) ExecuteSSE(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (*Response, error)

func (*Client) ExecuteWebSocket added in v0.5.0

func (c *Client) ExecuteWebSocket(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (*Response, error)

func (*Client) SetHTTPFactory added in v0.5.0

func (c *Client) SetHTTPFactory(factory func(Options) (*http.Client, error))

SetHTTPFactory allows callers to override how http.Client instances are created. Passing nil restores the default factory.

func (*Client) SetTelemetry added in v0.6.0

func (c *Client) SetTelemetry(instr telemetry.Instrumenter)

SetTelemetry configures the instrumenter used to emit OpenTelemetry spans. Passing nil restores the no-op implementation.

func (*Client) StartSSE added in v0.5.0

func (c *Client) StartSSE(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (*StreamHandle, *Response, error)

func (*Client) StartWebSocket added in v0.5.0

func (c *Client) StartWebSocket(
	ctx context.Context,
	req *restfile.Request,
	resolver *vars.Resolver,
	opts Options,
) (*WebSocketHandle, *Response, error)

type FileSystem

type FileSystem interface {
	ReadFile(name string) ([]byte, error)
}

type OSFileSystem

type OSFileSystem struct{}

func (OSFileSystem) ReadFile

func (OSFileSystem) ReadFile(name string) ([]byte, error)

type Options

type Options struct {
	Timeout            time.Duration
	FollowRedirects    bool
	InsecureSkipVerify bool
	ProxyURL           string
	RootCAs            []string
	RootMode           tlsconfig.RootMode
	ClientCert         string
	ClientKey          string
	HTTPVersion        httpver.Version
	BaseDir            string
	FallbackBaseDirs   []string
	NoFallback         bool
	Trace              bool
	TraceBudget        *nettrace.Budget
	SSH                *ssh.Plan
	K8s                *k8s.Plan
}

type Response

type Response struct {
	Status         string
	StatusCode     int
	Proto          string
	Headers        http.Header
	ReqMethod      string
	RequestHeaders http.Header
	ReqHost        string
	ReqLen         int64
	ReqTE          []string
	Body           []byte
	Duration       time.Duration
	EffectiveURL   string
	Request        *restfile.Request
	Timeline       *nettrace.Timeline
	TraceReport    *nettrace.Report
}

func CompleteSSE added in v0.5.0

func CompleteSSE(handle *StreamHandle) (*Response, error)

type SSEEvent added in v0.5.0

type SSEEvent struct {
	Index     int       `json:"index"`
	ID        string    `json:"id,omitempty"`
	Event     string    `json:"event,omitempty"`
	Data      string    `json:"data,omitempty"`
	Comment   string    `json:"comment,omitempty"`
	Retry     int       `json:"retry,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

type SSESummary added in v0.5.0

type SSESummary struct {
	EventCount int           `json:"eventCount"`
	ByteCount  int64         `json:"byteCount"`
	Duration   time.Duration `json:"duration"`
	Reason     string        `json:"reason"`
}

type SSETranscript added in v0.5.0

type SSETranscript struct {
	Events  []SSEEvent `json:"events"`
	Summary SSESummary `json:"summary"`
}

func DecodeSSETranscript added in v0.5.0

func DecodeSSETranscript(data []byte) (*SSETranscript, error)

type StreamHandle added in v0.5.0

type StreamHandle struct {
	Session *stream.Session
	Meta    StreamMeta
}

type StreamMeta added in v0.5.0

type StreamMeta struct {
	Status         string
	StatusCode     int
	Proto          string
	Headers        http.Header
	RequestHeaders http.Header
	RequestMethod  string
	RequestHost    string
	RequestLength  int64
	RequestTE      []string
	EffectiveURL   string
	ConnectedAt    time.Time
	Request        *restfile.Request
	BaseDir        string
}

type WebSocketEvent added in v0.5.0

type WebSocketEvent struct {
	Step      string    `json:"step,omitempty"`
	Direction string    `json:"direction"`
	Type      string    `json:"type"`
	Size      int       `json:"size"`
	Text      string    `json:"text,omitempty"`
	Base64    string    `json:"base64,omitempty"`
	Timestamp time.Time `json:"timestamp"`
	Code      int       `json:"code,omitempty"`
	Reason    string    `json:"reason,omitempty"`
}

type WebSocketHandle added in v0.5.0

type WebSocketHandle struct {
	Session *stream.Session
	Meta    StreamMeta
	Sender  *WebSocketSender
}

type WebSocketSender added in v0.5.0

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

func (*WebSocketSender) Close added in v0.5.0

func (s *WebSocketSender) Close(
	ctx context.Context,
	code websocket.StatusCode,
	reason string,
	meta map[string]string,
) error

func (*WebSocketSender) Ping added in v0.5.0

func (s *WebSocketSender) Ping(ctx context.Context, meta map[string]string) error

func (*WebSocketSender) Pong added in v0.5.0

func (s *WebSocketSender) Pong(ctx context.Context, payload string, meta map[string]string) error

func (*WebSocketSender) SendBase64 added in v0.5.0

func (s *WebSocketSender) SendBase64(
	ctx context.Context,
	data string,
	meta map[string]string,
) error

func (*WebSocketSender) SendBinary added in v0.5.0

func (s *WebSocketSender) SendBinary(
	ctx context.Context,
	data []byte,
	meta map[string]string,
) error

func (*WebSocketSender) SendJSON added in v0.5.0

func (s *WebSocketSender) SendJSON(
	ctx context.Context,
	jsonPayload string,
	meta map[string]string,
) error

func (*WebSocketSender) SendText added in v0.5.0

func (s *WebSocketSender) SendText(ctx context.Context, text string, meta map[string]string) error

type WebSocketSummary added in v0.5.0

type WebSocketSummary struct {
	SentCount     int           `json:"sentCount"`
	ReceivedCount int           `json:"receivedCount"`
	Duration      time.Duration `json:"duration"`
	ClosedBy      string        `json:"closedBy"`
	CloseCode     int           `json:"closeCode,omitempty"`
	CloseReason   string        `json:"closeReason,omitempty"`
}

type WebSocketTranscript added in v0.5.0

type WebSocketTranscript struct {
	Events  []WebSocketEvent `json:"events"`
	Summary WebSocketSummary `json:"summary"`
}

func DecodeWebSocketTranscript added in v0.5.0

func DecodeWebSocketTranscript(data []byte) (*WebSocketTranscript, error)

Jump to

Keyboard shortcuts

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