ddae5e721f0ab77229ac1007bcf746cbfb57a27a
This commit adds missing cookie handling cases to improve RFC 6265 compliance: Cookie Expiration: - Add expiration checking for both Expires and Max-Age attributes - Max-Age takes precedence over Expires per RFC 6265 - Automatic removal of expired cookies when processing responses - Store creation_time for accurate Max-Age calculation Cookie Management: - Update/replace existing cookies with same name, domain, and path - Prevent duplicate cookie entries in the jar - Consolidate multiple cookies into single Cookie header when sending Domain Handling: - Add domain validation to prevent servers from setting cookies for unrelated domains - Case-insensitive domain matching per RFC 6265 - Handle leading dots in Domain attribute (strip per RFC 6265 Section 5.2.3) - Subdomain matching for cookies without exact_domain flag Path Handling: - Implement RFC 6265 Section 5.1.4 default path computation - Use request path minus last component when Path attribute not specified - Fallback to "/" for edge cases Parser Improvements: - Add SameSite attribute support (None, Lax, Strict) - Gracefully ignore unknown/extension cookie attributes instead of failing - Forward compatibility with future cookie attributes Other: - Add time.h include for time() and time_t - Add http_date_to_time() helper for expiration comparison - Add is_cookie_expired() helper for expiration checks - Add compute_default_cookie_path() per RFC 6265
cHTTP
This is an HTTP library for C, featuring an HTTP(S) server, HTTP(S) client, and much more!
Contributing
Contributions are welcome! The following are some notes on how to work with the codebase. Don't worry if you get something wrong. I will remind you.
The source code in the src/ directory is intended to be be amalgamated into a single file before compilation. The amalgamation is not only intended as a distribution method, but also as easy-access documentation, and therefore need to be readable. For this reasons:
- You never need need to include other cHTTP source files
- All inclusions of third-party headers are to be placed inside
src/includes.h - All files must start with a single empty line, unless they start with an overview comment of the file, in which case they must have no empty lines at the beginning of the file.
- All files must end with a single empty line.
Languages
C
98.9%
Python
0.9%
Makefile
0.2%