Skip to content

v2: Implement Network Handling (HTTP Metadata, Conditional Requests, Request Config) #247

@mmcdole

Description

@mmcdole

Overview

Implement comprehensive network handling for ParseURL including HTTP response metadata, conditional requests, and request configuration using the RequestOptions sub-struct from #244.

Tasks

Request Configuration

  • Use RequestOptions from ParseOptions for HTTP configuration:
    • Apply custom Client if provided
    • Set Timeout on HTTP client
    • Set UserAgent header
    • Apply AuthConfig for basic auth

Conditional Requests

  • Implement conditional request support:
    • Send If-None-Match header when IfNoneMatch is set in RequestOptions
    • Send If-Modified-Since header when IfModifiedSince is set
    • Return ErrNotModified for 304 responses
    • Handle 304 responses gracefully

Response Metadata

  • Add ResponseMetadata struct to gofeed.Feed:

    type ResponseMetadata struct {
        StatusCode int
        ETag string
        LastModified time.Time
        CacheControl struct {
            MaxAge *time.Duration
            MustRevalidate bool
            NoCache bool
            NoStore bool
        }
        RetryAfter *time.Time
        Expires *time.Time
    }
  • Parse and populate HTTP headers:

    • ETag response header
    • Last-Modified header (parse HTTP date)
    • Cache-Control directives (max-age, must-revalidate, no-cache, no-store)
    • Retry-After header (both HTTP-date and delay-seconds formats)
    • Expires header

Testing & Documentation

  • Add comprehensive tests for all network functionality
  • Document usage patterns for:
    • Conditional requests to reduce bandwidth
    • Cache control interpretation
    • Retry-After handling for rate limiting

Benefits

  • Enable proper HTTP caching strategies
  • Support conditional requests to reduce unnecessary fetches
  • Provide scheduling hints from HTTP headers
  • Better HTTP client configuration support

Related Issues

Parent Issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Version 2 related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions