httpcap

package
v0.0.0-...-f5a5a56 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptureClient

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

CaptureClient provides HTTP request/response capture and storage capabilities

func NewCaptureClient

func NewCaptureClient(workspace *core.Workspace, config *CaptureConfig, logger zerolog.Logger) *CaptureClient

NewCaptureClient creates a new HTTP capture client

func (*CaptureClient) Do

Do performs an HTTP request with full capture

func (*CaptureClient) Get

Get performs a GET request with capture

func (*CaptureClient) GetStats

func (c *CaptureClient) GetStats() CaptureStats

GetStats returns current capture statistics

func (*CaptureClient) Post

func (c *CaptureClient) Post(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, *CapturedRequest, *CapturedResponse, error)

Post performs a POST request with capture

type CaptureConfig

type CaptureConfig struct {
	Timeout            time.Duration `json:"timeout"`
	MaxRedirects       int           `json:"max_redirects"`
	UserAgent          string        `json:"user_agent"`
	MaxBodySize        int64         `json:"max_body_size"`
	StoreRawBodies     bool          `json:"store_raw_bodies"`
	CompressStorage    bool          `json:"compress_storage"`
	FollowRobots       bool          `json:"follow_robots"`
	EnableCookies      bool          `json:"enable_cookies"`
	InsecureSkipVerify bool          `json:"insecure_skip_verify"`
	MaxIdleConns       int           `json:"max_idle_conns"`
	IdleConnTimeout    time.Duration `json:"idle_conn_timeout"`
}

CaptureConfig defines configuration for the HTTP capture client

func DefaultCaptureConfig

func DefaultCaptureConfig() *CaptureConfig

DefaultCaptureConfig returns default capture configuration

type CaptureStats

type CaptureStats struct {
	TotalRequests  int64            `json:"total_requests"`
	TotalResponses int64            `json:"total_responses"`
	TotalBytes     int64            `json:"total_bytes"`
	AverageLatency time.Duration    `json:"average_latency"`
	StatusCodes    map[int]int64    `json:"status_codes"`
	ContentTypes   map[string]int64 `json:"content_types"`
	ErrorCount     int64            `json:"error_count"`
	StartTime      time.Time        `json:"start_time"`
	LastActivity   time.Time        `json:"last_activity"`
	// contains filtered or unexported fields
}

CaptureStats tracks capture statistics

type CapturedRequest

type CapturedRequest struct {
	ID          string            `json:"id"`
	Method      string            `json:"method"`
	URL         string            `json:"url"`
	Proto       string            `json:"proto"`
	Headers     map[string]string `json:"headers"`
	Body        string            `json:"body,omitempty"`
	BodyHash    string            `json:"body_hash"`
	BodySize    int64             `json:"body_size"`
	Timestamp   time.Time         `json:"timestamp"`
	RemoteAddr  string            `json:"remote_addr"`
	UserAgent   string            `json:"user_agent"`
	Referrer    string            `json:"referrer"`
	ContentType string            `json:"content_type"`
}

CapturedRequest represents a captured HTTP request

type CapturedResponse

type CapturedResponse struct {
	ID              string            `json:"id"`
	RequestID       string            `json:"request_id"`
	StatusCode      int               `json:"status_code"`
	Status          string            `json:"status"`
	Proto           string            `json:"proto"`
	Headers         map[string]string `json:"headers"`
	Body            string            `json:"body,omitempty"`
	BodyHash        string            `json:"body_hash"`
	BodySize        int64             `json:"body_size"`
	Timestamp       time.Time         `json:"timestamp"`
	Duration        time.Duration     `json:"duration"`
	Server          string            `json:"server"`
	ContentType     string            `json:"content_type"`
	ContentEncoding string            `json:"content_encoding"`
	Location        string            `json:"location,omitempty"`
	SetCookies      []string          `json:"set_cookies,omitempty"`
	Technologies    []string          `json:"technologies,omitempty"`
}

CapturedResponse represents a captured HTTP response

type RequestStorage

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

RequestStorage handles storage of captured requests

func (*RequestStorage) LoadRequest

func (rs *RequestStorage) LoadRequest(requestID string) (*CapturedRequest, error)

LoadRequest loads a captured request by ID

func (*RequestStorage) Store

func (rs *RequestStorage) Store(req *CapturedRequest) error

Store stores a captured request

type ResponseStorage

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

ResponseStorage handles storage of captured responses

func (*ResponseStorage) LoadResponse

func (rs *ResponseStorage) LoadResponse(responseID string) (*CapturedResponse, error)

LoadResponse loads a captured response by ID

func (*ResponseStorage) Store

func (rs *ResponseStorage) Store(resp *CapturedResponse) error

Store stores a captured response

type RobotsData

type RobotsData struct {
	UserAgent   string    `json:"user_agent"`
	Disallowed  []string  `json:"disallowed"`
	Allowed     []string  `json:"allowed"`
	CrawlDelay  int       `json:"crawl_delay"`
	Sitemap     []string  `json:"sitemap"`
	LastFetched time.Time `json:"last_fetched"`
}

RobotsData represents parsed robots.txt data

Jump to

Keyboard shortcuts

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