← 输入框|github.com|刷新
Skip to content

Optimize HEAD requests for stats endpoint - #592

Open
softko wants to merge 3 commits into
tinyproxy:masterfrom
softko:optimize-head-stats-requests
Open

softko wants to merge 3 commits into
tinyproxy:masterfrom
softko:optimize-head-stats-requests

Conversation

@softko

@softko softko commented Dec 14, 2025

Copy link
Copy Markdown

Summary

Optimize HEAD requests for the stats endpoint by skipping response body generation and transmission while maintaining full functionality for GET requests.

Changes

  • Add http_method field to connection structure to store HTTP method
  • Store HTTP method during request processing for later use in stats handling
  • Skip response body generation and transmission for HEAD requests to stats endpoint
  • Maintain backward compatibility for all existing GET request functionality

Benefits

  • Reduced I/O overhead: HEAD requests no longer read stats template files unnecessarily
  • Reduced network traffic: No response body transmitted for HEAD requests
  • Improved RFC compliance: Proper HEAD method semantics (headers without body)
  • Zero performance impact: No overhead for existing GET requests
  • Full backward compatibility: All existing functionality preserved

Testing

  • Verified successful compilation with no warnings
  • Confirmed HEAD vs GET request detection logic works correctly
  • All existing functionality remains unchanged

This addresses the performance optimization opportunity where HEAD requests were previously processing and sending the full response body unnecessarily.

- Add http_method field to connection structure to store HTTP method
- Store HTTP method during request processing for later use
- Skip response body generation and transmission for HEAD requests to stats endpoint
- Maintain full functionality for GET requests
- Reduces I/O overhead and network traffic for HEAD requests
- Improves RFC compliance by properly handling HEAD method semantics

This change ensures HEAD requests to the stats endpoint return appropriate
headers without the response body, reducing unnecessary file I/O and network
overhead while maintaining backward compatibility.
Comment thread src/conns.h Resolved
@softko

softko commented Aug 15, 2026

Copy link
Copy Markdown
Author

@rofl0r hello will this move forward?

@rofl0r

rofl0r commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

yeah it's on my TODO list for testing & integration before the next release. currently i'm running my PR #622 in production to see if i can catch any potential issues during live use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants