fetcher

package
v0.0.0-...-d07f01d Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Unlicense Imports: 14 Imported by: 0

Documentation

Overview

Package fetcher performs well-behaved HTTP feed retrieval following the rachelbythebay Feed Reader Behavior project (FRB) and earth.org.uk RSS-efficiency recommendations: conditional GETs, identifying User-Agent, compression, server-hint parsing and manual redirect handling.

Index

Constants

This section is empty.

Variables

View Source
var Version string

Version can be set at build time via -ldflags "-X github.com/Brawl345/rssbot/fetcher.Version=...". Otherwise the VCS revision embedded by the Go toolchain is used.

Functions

This section is empty.

Types

type Fetcher

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

func New

func New() *Fetcher

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, feedURL, etag, lastModified string) (*Result, error)

Fetch issues a single conditional GET for feedURL. etag and lastModified, if non-empty, are sent back verbatim as If-None-Match / If-Modified-Since.

func (*Fetcher) UserAgent

func (f *Fetcher) UserAgent() string

UserAgent returns the identifying User-Agent string sent with every request.

type Result

type Result struct {
	Status       int
	NotModified  bool          // 304: nothing changed since the conditional request
	Feed         *gofeed.Feed  // only set on 200 with a parseable feed
	ETag         string        // exactly as received (FRB003)
	LastModified string        // exactly as received (FRB001)
	MaxAge       time.Duration // Cache-Control: max-age (FRB022), 0 if absent
	RetryAfter   time.Duration // Retry-After on 429/503 (FRB020/021), 0 if absent
	FeedInterval time.Duration // ttl hint (FRB023/024), 0 if absent
	SkipHours    []int         // RSS skipHours (FRB024)
	SkipDays     []string      // RSS skipDays (FRB024)
	PermanentURL string        // set on a 301/308 chain ending in 200/304 (FRB130/131)
	Body         string        // snippet of an error body for the user (FRB101/120)
}

Result is the interpreted outcome of a single feed fetch. ETag and LastModified form an atomic set (FRB014) and are only populated from a status 200 response.

Jump to

Keyboard shortcuts

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