gofeed icon indicating copy to clipboard operation
gofeed copied to clipboard

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

Open mmcdole opened this issue 7 months ago • 0 comments

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

  • #111 (HTTP ETag, Last-Modified, conditional requests)
  • #165 (Proxy/custom HTTP client support)
  • #228 (Scheduling hints)
  • #244 (ParseOptions implementation)

Parent Issue

  • #241 (RFC: gofeed v2)

mmcdole avatar May 26 '25 04:05 mmcdole