httpvalidator

package
v0.0.0-...-ae8aba3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalHeaderKey

func CanonicalHeaderKey(key string) string

Types

type HTTPValidator

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

func NewHTTPValidator

func NewHTTPValidator(appCfg *config.AppConfig) *HTTPValidator

func (*HTTPValidator) Validate

func (hv *HTTPValidator) Validate(
	ctx context.Context,
	domain string,
	initialURL string,
	persona *models.Persona,
	proxy *models.Proxy,
) (*ValidationResult, error)

func (*HTTPValidator) ValidateHeadless

func (hv *HTTPValidator) ValidateHeadless(
	ctx context.Context, domain string, initialURL string,
	persona *models.Persona, proxy *models.Proxy,
) (*ValidationResult, error)

type ValidationResult

type ValidationResult struct {
	Domain                  string              `json:"domain"`             // The domain that was targeted
	AttemptedURL            string              `json:"attemptedUrl"`       // The initial URL attempted for validation
	FinalURL                string              `json:"finalUrl,omitempty"` // URL after all redirects
	IsSuccess               bool                `json:"isSuccess"`          // True if validation met persona criteria
	Status                  string              `json:"status"`             // Descriptive status, e.g., "Validated", "FetchError", "StatusCodeMismatch", "ContentMismatch", "HeadlessFailed"
	StatusCode              int                 `json:"statusCode,omitempty"`
	ResponseHeaders         map[string][]string `json:"responseHeaders,omitempty"`
	ContentHash             string              `json:"contentHash,omitempty"`             // SHA256 hash of the response body
	ContentLength           int                 `json:"contentLength,omitempty"`           // Length of body read for hashing/analysis
	ActualContentLength     int64               `json:"actualContentLength,omitempty"`     // From Content-Length header or full body if read
	ContentHashError        string              `json:"contentHashError,omitempty"`        // Error if hashing failed
	ExtractedTitle          string              `json:"extractedTitle,omitempty"`          // Extracted <title> from the page
	ExtractedContentSnippet string              `json:"extractedContentSnippet,omitempty"` // Extracted snippet of content
	AntiBotIndicators       map[string]string   `json:"antiBotIndicators,omitempty"`       // Detected anti-bot measures
	Error                   string              `json:"error,omitempty"`                   // Detailed error message if any step failed

	// Headless-specific results
	IsHeadless      bool   `json:"isHeadless,omitempty"`      // True if this result is from a headless browser attempt
	ScreenshotPath  string `json:"screenshotPath,omitempty"`  // Relative path to screenshot (if taken)
	DOMSnapshotPath string `json:"domSnapshotPath,omitempty"` // Relative path to DOM snapshot (if taken)

	Timestamp  time.Time `json:"timestamp"`  // Timestamp of when the validation attempt was made
	DurationMs int64     `json:"durationMs"` // Duration of the validation attempt in milliseconds

	UsedProxyID string `json:"usedProxyId,omitempty"` // ID of the proxy used for this validation

	RawBody []byte `json:"-"` // Raw response body, not included in JSON response by default, but available for internal processing
}

ValidationResult holds the result of a single domain HTTP validation attempt. This can be from a standard HTTP client or a headless browser.

Jump to

Keyboard shortcuts

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