4df3e44eff
Add failing tests for ETag, HEAD requests, and conditional requests
...
TDD: Write tests first before implementation for:
- ETag generation and consistency in service layer
- HEAD request support (headers only, no body)
- Conditional requests with If-None-Match header (304 responses)
2026-01-08 10:06:18 -08:00
95408e68d4
Implement max input dimensions and path traversal validation
...
- Reject input images exceeding MaxInputDimension (8192px) to prevent DoS
- Detect path traversal: ../, encoded variants, backslashes, null bytes
2026-01-08 08:50:18 -08:00
c964feac7e
Add failing tests for input dimension and path traversal validation
...
Tests for:
- ErrInputTooLarge when input image exceeds MaxInputDimension
- ErrPathTraversal for ../, encoded traversal, backslashes, null bytes
2026-01-08 08:48:11 -08:00
2cbafe374c
Add mock fetcher and service tests for imgcache
...
Introduces Fetcher interface, mock implementation for testing,
and ApplyMigrations helper for test database setup.
2026-01-08 07:39:18 -08:00
f244d9c7e0
Add per-host connection limits for upstream fetching
...
- Add upstream_connections_per_host config option (default: 20)
- Implement per-host semaphores to limit concurrent connections
- Semaphore released when response body is closed
- Prevents overwhelming origin servers with parallel requests
2026-01-08 05:19:20 -08:00
6304556837
Refactor to serve all responses from cached files on disk
...
- StoreOutput now returns output hash for immediate retrieval
- Cache misses now serve from disk file after storing (same as hits)
- Log served_bytes from actual io.Copy result (avoids stat calls)
- Remove ContentLength field usage for cache hits (stream from file)
- Fix tests to properly check all return values
2026-01-08 05:11:55 -08:00
1a97f42cd8
Add detailed logging for image requests with cache status and timing
2026-01-08 05:04:08 -08:00
fd2d108f9c
Wire up image handler endpoint with service orchestration
...
- Add image proxy config options (signing_key, whitelist_hosts, allow_http)
- Create Service to orchestrate cache, fetcher, and processor
- Initialize image service in handlers OnStart hook
- Implement HandleImage with URL parsing, signature validation, cache
- Implement HandleRobotsTxt for search engine prevention
- Parse query params for signature, quality, and fit mode
2026-01-08 04:01:53 -08:00
5462c9222c
Add pure Go image processor with resize and format conversion
...
Implements the Processor interface using disintegration/imaging library.
Supports JPEG, PNG, GIF, WebP decoding and JPEG, PNG, GIF encoding.
Includes all fit modes: cover, contain, fill, inside, outside.
2026-01-08 03:54:50 -08:00
9629139989
Add tests for cache service
...
Tests cover: lookup miss/hit, store source/output, negative caching,
negative cache expiry, hot cache, output retrieval, stats, and cleanup.
2026-01-08 03:39:23 -08:00
6d32b7ee23
Fix formatting in fetcher and signature tests
2026-01-08 03:36:00 -08:00
30c5c077e5
Add cache service with hot cache and negative caching
...
Implements cache lookup with in-memory hot path, source/output storage,
negative caching for failed fetches, TTL expiration, and statistics tracking.
2026-01-08 03:35:55 -08:00
2f20c71da0
Add content-addressable storage and cache key generation
...
ContentStorage stores blobs at <dir>/<ab>/<cd>/<sha256> paths.
MetadataStorage stores JSON at <dir>/<host>/<path_hash>.json.
CacheKey generates unique keys from request parameters.
2026-01-08 03:35:50 -08:00
30d63e80dc
Add magic byte detection for image format validation
...
Implements format detection by checking file magic bytes for JPEG, PNG,
GIF, WebP, AVIF, and SVG. Includes validation against declared Content-Type.
2026-01-08 03:35:29 -08:00
cc2c40bfbf
Implement HMAC-SHA256 signature generation and verification
2026-01-08 03:02:09 -08:00
2b0ccd6052
Implement host whitelist for source domains
2026-01-08 03:00:53 -08:00
018c280267
Add ParseImagePath for chi wildcard and upstream fetcher with SSRF protection
2026-01-08 02:59:48 -08:00
c69ddf6f61
Implement URL parser for image proxy routes
2026-01-08 02:55:05 -08:00
827f9743b8
Add package and const block comments to imgcache
2026-01-08 02:29:25 -08:00
ef6e67e786
Add blank line before return in SourceURL
2026-01-08 02:23:23 -08:00
516853626d
Add basic webserver skeleton with healthcheck
2026-01-08 02:20:23 -08:00