feat: Complete Phase 2.4 - HTTP Content Negotiation

Implements HTTP content negotiation for feed format selection.

Phase 2.4 Deliverables:
- Content negotiation via Accept header parsing
- Quality factor support (q= parameter)
- 5 feed endpoints with format routing
- 406 Not Acceptable responses with helpful errors
- Comprehensive test coverage (63 tests)

Endpoints:
- /feed - Content negotiation based on Accept header
- /feed.rss - Explicit RSS 2.0
- /feed.atom - Explicit ATOM 1.0
- /feed.json - Explicit JSON Feed 1.1
- /feed.xml - Backward compatibility (→ RSS)

MIME Type Mapping:
- application/rss+xml → RSS 2.0
- application/atom+xml → ATOM 1.0
- application/feed+json or application/json → JSON Feed 1.1
- */* → RSS 2.0 (default)

Implementation:
- Simple quality factor parsing (StarPunk philosophy)
- Not full RFC 7231 compliance (minimal approach)
- Reuses existing feed generators
- No breaking changes

Quality Metrics:
- 132/132 tests passing (100%)
- Zero breaking changes
- Full backward compatibility
- Standards compliant negotiation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-27 20:46:49 -07:00
parent 59e9d402c6
commit 8fbdcb6e6f
9 changed files with 1951 additions and 43 deletions

View File

@@ -7,10 +7,12 @@ with content negotiation and caching support.
Exports:
generate_rss: Generate RSS 2.0 feed
generate_rss_streaming: Generate RSS 2.0 feed with streaming
generate_atom: Generate ATOM 1.0 feed (coming in Phase 2.2)
generate_atom_streaming: Generate ATOM 1.0 feed with streaming (coming in Phase 2.2)
generate_json_feed: Generate JSON Feed 1.1 (coming in Phase 2.3)
generate_json_feed_streaming: Generate JSON Feed 1.1 with streaming (coming in Phase 2.3)
generate_atom: Generate ATOM 1.0 feed
generate_atom_streaming: Generate ATOM 1.0 feed with streaming
generate_json_feed: Generate JSON Feed 1.1
generate_json_feed_streaming: Generate JSON Feed 1.1 with streaming
negotiate_feed_format: Content negotiation for feed formats
get_mime_type: Get MIME type for a format name
"""
from .rss import (
@@ -31,6 +33,11 @@ from .json_feed import (
generate_json_feed_streaming,
)
from .negotiation import (
negotiate_feed_format,
get_mime_type,
)
__all__ = [
# RSS functions
"generate_rss",
@@ -44,4 +51,7 @@ __all__ = [
# JSON Feed functions
"generate_json_feed",
"generate_json_feed_streaming",
# Content negotiation
"negotiate_feed_format",
"get_mime_type",
]