classify

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package classify categorizes HTTP responses into deterministic crawl outcomes (ok, challenge, stop, gone, skip, error, not_tried) before upstream parsers inspect response bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptFor

func AcceptFor(kind Kind, requested string) (string, error)

AcceptFor validates `(kind, requestedAccept)` and returns the outbound `Accept` header value.

func StopsHost

func StopsHost(kind Kind, o Outcome) bool

StopsHost reports whether `outcome` on `kind` should leave remaining queued URLs for the same host `not_tried`.

Types

type Kind

type Kind string

Kind identifies what resource shape the caller expects from a URL.

const (
	KindFeed    Kind = "feed"    // Structured JSON product feed (`{"products": [...]}`)
	KindJSON    Kind = "json"    // Any valid 2xx JSON document
	KindPage    Kind = "page"    // Individual HTML document (`text/html`, 404/410 -> `gone`)
	KindText    Kind = "text"    // Auxiliary HTML or XML document (e.g., sitemap or collection)
	KindCatalog Kind = "catalog" // Full-catalog HTML page where non-2xx fails the host batch
)

type Outcome

type Outcome string

Outcome describes how the crawler and caller should act on an HTTP response.

const (
	OutcomeOK        Outcome = "ok"
	OutcomeChallenge Outcome = "challenge" // Edge anti-bot challenge (`cf-mitigated`) — never retried
	OutcomeStop      Outcome = "stop"      // Origin answered 403, 429, or 503 — halt remaining URLs for this host
	OutcomeGone      Outcome = "gone"      // Document answered 404 or 410
	OutcomeSkip      Outcome = "skip"      // Non-200 or non-HTML page that can be skipped without failing the host
	OutcomeError     Outcome = "error"     // Feed/transport failure
	OutcomeNotTried  Outcome = "not_tried" // Left unsent because an earlier request stopped the host or timed out
)

func Classify

func Classify(kind Kind, status int, header http.Header, body []byte) (Outcome, string)

Classify evaluates status code, response headers, and body bytes to determine `(Outcome, problem)`.

Note that Go `switch` cases do NOT fall through unless `fallthrough` is written explicitly, and multiple values can share one `case 403, 429, 503:` branch cleanly.

Jump to

Keyboard shortcuts

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