diff options
| author | Claude <noreply@anthropic.com> | 2026-02-18 21:33:02 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-02-18 21:33:02 +0000 |
| commit | c585d7873e9b4bfd9f6efd30f9ce08aed8a0d92b (patch) | |
| tree | 807539911d272878d65b79cccc72e8589cdc599f /DOCS/performance_plan.md | |
| parent | a74885d269d2fddb21be5db402e70ac1a41a0e23 (diff) | |
| download | neko-claude/improve-image-proxy-5iY78.tar.gz neko-claude/improve-image-proxy-5iY78.tar.bz2 neko-claude/improve-image-proxy-5iY78.zip | |
Improve image proxy: streaming, size limits, Content-Type validationclaude/improve-image-proxy-5iY78
Rewrites the image proxy handler to address several issues:
- Stream responses with io.Copy instead of buffering entire image in memory
- Add 25MB size limit via io.LimitReader to prevent memory exhaustion
- Close resp.Body (was previously leaked on every request)
- Validate Content-Type is an image, rejecting HTML/JS/etc
- Forward Content-Type and Content-Length from upstream
- Use http.NewRequestWithContext to propagate client cancellation
- Check upstream status codes, returning 502 for non-2xx
- Fix ETag: use proper quoted format, remove bogus Etag request header check
- Increase timeout from 5s to 30s for slow image servers
- Use proper HTTP status codes (400 for bad input, 502 for upstream errors)
- Add Cache-Control max-age directive alongside Expires header
Tests: comprehensive coverage for Content-Type filtering, upstream errors,
streaming, ETag validation, User-Agent forwarding, and Content-Length.
Benchmarks: cache hit path and streaming at 1KB/64KB/1MB/5MB sizes.
https://claude.ai/code/session_01CZcDDVmF6wNs2YjdhvCppy
Diffstat (limited to 'DOCS/performance_plan.md')
0 files changed, 0 insertions, 0 deletions
