Documentation
¶
Index ¶
- Constants
- func ApplyOptionSettings(opts *Options, settings map[string]string) error
- func ParseForwardCredentials(val string) (origin.Set, error)
- type AttemptPlan
- type AuthPlacement
- type AuthPlan
- type AuthValue
- type Client
- func (c *Client) BuildHTTPRequest(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*http.Request, Options, []byte, error)
- func (c *Client) Clone() *Client
- func (c *Client) CompleteWebSocket(ctx context.Context, handle *WebSocketHandle, req *restfile.Request, ...) (*Response, error)
- func (c *Client) Execute(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (resp *Response, err error)
- func (c *Client) ExecuteSSE(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*Response, error)
- func (c *Client) ExecuteWebSocket(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*Response, error)
- func (c *Client) PrepareAttempts(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*AttemptPlan, error)
- func (c *Client) StartSSE(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*StreamHandle, *Response, error)
- func (c *Client) StartWebSocket(ctx context.Context, req *restfile.Request, resolver *vars.Resolver, ...) (*WebSocketHandle, *Response, error)
- type ClientOption
- type HTTPClientFactory
- type Options
- type Response
- type ResponseTooLargeError
- type SSEEvent
- type SSESummary
- type SSETranscript
- type StreamHandle
- type StreamMeta
- type WebSocketDialer
- type WebSocketEvent
- type WebSocketHandle
- type WebSocketSender
- func (s *WebSocketSender) Close(ctx context.Context, code stream.WSCloseCode, reason, step string) error
- func (s *WebSocketSender) Ping(ctx context.Context, payload, step string) error
- func (s *WebSocketSender) Pong(ctx context.Context, payload, step string) error
- func (s *WebSocketSender) SendBase64(ctx context.Context, data, step string) error
- func (s *WebSocketSender) SendBinary(ctx context.Context, data []byte, step string) error
- func (s *WebSocketSender) SendJSON(ctx context.Context, jsonPayload, step string) error
- func (s *WebSocketSender) SendText(ctx context.Context, text, step string) error
- type WebSocketSummary
- type WebSocketTranscript
Constants ¶
const ( StreamHeaderType = "X-Resterm-Stream-Type" StreamHeaderSummary = "X-Resterm-Stream-Summary" )
Resterm adds these headers so streaming results can use the normal response, history, and rendering paths. They do not come from the server.
const ( DefaultSSEMaxLineBytes = 4 << 20 DefaultSSEMaxEventBytes = 8 << 20 DefaultSSESessionBytes = 16 << 20 )
const DefaultMaxRedirects = 10
const DefaultMaxResponseBytes = 32 << 20
const DefaultWebSocketTranscriptBytes = 8 << 20
Variables ¶
This section is empty.
Functions ¶
func ApplyOptionSettings ¶
ApplyOptionSettings applies the generic HTTP settings recognized by the client and reports the first value it cannot read.
Types ¶
type AttemptPlan ¶ added in v1.4.0
type AttemptPlan struct {
// contains filtered or unexported fields
}
AttemptPlan stores one prepared request so it can be sent more than once. Templates and authentication are resolved only once.
type AuthPlan ¶ added in v1.5.0
type AuthPlan struct {
Values []AuthValue
Targets []string
// Digest holds credentials for the retry after a server challenge.
Digest *digest.Credentials
}
type AuthValue ¶
type AuthValue struct {
Placement AuthPlacement
Name string
Value string
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(fs filelookup.FileSystem) *Client
func NewClientWithOptions ¶
func NewClientWithOptions(opts ...ClientOption) *Client
func (*Client) BuildHTTPRequest ¶
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) Clone ¶
Clone returns a snapshot of c's client configuration. Later field updates on c do not affect the clone.
func (*Client) CompleteWebSocket ¶
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 ¶
func (*Client) ExecuteWebSocket ¶
func (*Client) PrepareAttempts ¶ added in v1.4.0
func (c *Client) PrepareAttempts( ctx context.Context, req *restfile.Request, resolver *vars.Resolver, opts Options, ) (*AttemptPlan, error)
PrepareAttempts resolves a request once and buffers its body for reuse.
type ClientOption ¶
type ClientOption func(*Client)
func WithFileSystem ¶
func WithFileSystem(fs filelookup.FileSystem) ClientOption
func WithHTTPFactory ¶
func WithHTTPFactory(factory HTTPClientFactory) ClientOption
func WithTelemetry ¶
func WithTelemetry(instr telemetry.Instrumenter) ClientOption
func WithWebSocketDialer ¶
func WithWebSocketDialer(dialer WebSocketDialer) ClientOption
type Options ¶
type Options struct {
Timeout time.Duration
MaxResponseBytes bytesize.Budget
SSEMaxLineBytes int64
SSEMaxEventBytes int64
WSMaxMessageBytes int64
WSCompression restfile.Opt[bool]
BaseURL string
FollowRedirects bool
MaxRedirects restfile.Opt[int]
CredentialHeaders []string
ForwardCredentials origin.Set
ConfineToOrigin bool
InsecureSkipVerify bool
ProxyURL string
RootCAs []string
RootMode tlsconfig.RootMode
ClientCert string
ClientKey string
HTTPVersion version.HTTP
BaseDir string
FallbackBaseDirs []string
NoFallback bool
Trace bool
TraceBudget *nettrace.Budget
SSH *ssh.Plan
K8s *k8s.Plan
CookieJar http.CookieJar
// contains filtered or unexported fields
}
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 ¶
func CompleteSSE(handle *StreamHandle) (*Response, error)
func StreamingWebSocketResponse ¶
func StreamingWebSocketResponse(meta StreamMeta) *Response
This temporary response lets the UI show an interactive WebSocket before the session closes and its final transcript is available.
func (*Response) SentHeaders ¶ added in v1.13.0
SentHeaders adds the headers net/http writes from request fields, which RequestHeaders does not hold.
type ResponseTooLargeError ¶ added in v1.5.0
type ResponseTooLargeError struct {
Limit int64
}
func (*ResponseTooLargeError) Error ¶ added in v1.5.0
func (e *ResponseTooLargeError) Error() string
type SSESummary ¶
type SSESummary struct {
EventCount int `json:"eventCount"`
ByteCount int64 `json:"byteCount"`
Duration time.Duration `json:"duration"`
Reason string `json:"reason"`
Dropped int64 `json:"dropped,omitempty"`
Error string `json:"error,omitempty"`
ErrorClass diag.Class `json:"errorClass,omitempty"`
}
func (SSESummary) Err ¶ added in v1.5.0
func (s SSESummary) Err() error
Err reports an error when the stream fails, is canceled, or exceeds a caller deadline. Configured stream limits are normal endings.
type SSETranscript ¶
type SSETranscript struct {
Events []SSEEvent `json:"events"`
Summary SSESummary `json:"summary"`
}
func DecodeSSETranscript ¶
func DecodeSSETranscript(data []byte) (*SSETranscript, error)
type StreamHandle ¶
type StreamHandle struct {
Session *stream.Session
Meta StreamMeta
}
type StreamMeta ¶
type WebSocketDialer ¶
type WebSocketEvent ¶
type WebSocketEvent struct {
Step string `json:"step,omitempty"`
Direction string `json:"direction"`
Type stream.WSType `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 ¶
type WebSocketHandle struct {
Session *stream.Session
Meta StreamMeta
Sender *WebSocketSender
}
type WebSocketSender ¶
type WebSocketSender struct {
// contains filtered or unexported fields
}
func (*WebSocketSender) Close ¶
func (s *WebSocketSender) Close(ctx context.Context, code stream.WSCloseCode, reason, step string) error
func (*WebSocketSender) Ping ¶
func (s *WebSocketSender) Ping(ctx context.Context, payload, step string) error
func (*WebSocketSender) Pong ¶
func (s *WebSocketSender) Pong(ctx context.Context, payload, step string) error
func (*WebSocketSender) SendBase64 ¶
func (s *WebSocketSender) SendBase64(ctx context.Context, data, step string) error
func (*WebSocketSender) SendBinary ¶
type WebSocketSummary ¶
type WebSocketSummary struct {
SentCount int `json:"sentCount"`
ReceivedCount int `json:"receivedCount"`
Duration time.Duration `json:"duration"`
ClosedBy stream.WSClosedBy `json:"closedBy"`
CloseCode int `json:"closeCode,omitempty"`
CloseReason string `json:"closeReason,omitempty"`
Dropped int64 `json:"dropped,omitempty"`
ErrorClass diag.Class `json:"errorClass,omitempty"`
}
func (WebSocketSummary) Err ¶ added in v1.5.0
func (s WebSocketSummary) Err() error
Err reports an error when the session fails, is canceled, or exceeds a caller deadline. A close from either side and an idle timeout are normal endings.
type WebSocketTranscript ¶
type WebSocketTranscript struct {
Events []WebSocketEvent `json:"events"`
Summary WebSocketSummary `json:"summary"`
}
func DecodeWebSocketTranscript ¶
func DecodeWebSocketTranscript(data []byte) (*WebSocketTranscript, error)
Source Files
¶
- attempt.go
- auth.go
- body.go
- client.go
- cookieurl_go126.go
- digest.go
- fs.go
- limits.go
- options_apply.go
- redirect.go
- request.go
- request_build.go
- resp_helpers.go
- stream_headers.go
- stream_helpers.go
- stream_idle.go
- stream_sse.go
- stream_sse_accumulator.go
- stream_sse_wire.go
- stream_transcript.go
- stream_types.go
- stream_ws.go
- stream_ws_accumulator.go
- stream_ws_runtime.go
- stream_ws_sender.go
- stream_ws_steps.go
- target.go
- trace.go
- trace_details.go
- transport.go
- version.go
- ws_linkname.go