Implemented missing functionality in the Set-Cookie parser:
1. Completed is_cookie_octet() function to properly validate cookie characters
according to RFC 6265 (excludes CTLs, whitespace, DQUOTE, comma, semicolon, backslash)
2. Fixed http_parse_set_cookie() return type from void to int to properly
report parsing errors
3. Implemented Path attribute parsing to extract cookie path restrictions
4. Fixed HttpOnly attribute bug where it was incorrectly set to false instead of true
5. Added path field to HTTP_SetCookie struct with have_path flag
6. Added missing return 0 statement for successful parsing
7. Exported Set-Cookie parser types and function to public API:
- HTTP_WeekDay, HTTP_Month, HTTP_Date enums/struct
- HTTP_SetCookie struct
- http_parse_set_cookie() function
All changes follow RFC 6265 specification for Set-Cookie header parsing.
Based on code review feedback:
Client improvements:
- Remove redundant capacity check in http_client_get_builder
(already verified num_conns < capacity)
- Fix generation counter - no longer reset to zero when allocating
connections, only incremented on request send
- Add HTTP_Method parameter to http_request_builder_url instead
of hardcoding GET method
- Free connection resources when http_request_builder_send fails
(invalid host mode or socket_connect failure)
Server bug fix:
- Fix ready queue indexing in http_server_next_request
Changed: &server->conns[server->ready_head]
To: &server->conns[server->ready[server->ready_head]]
This bug would have caused incorrect connection retrieval
All changes maintain consistency with the codebase style and
improve robustness of error handling.
Refactored HTTP client implementation to follow the same coding
patterns and style as server.c:
- Added static helper functions (http_client_conn_init,
http_client_conn_free, check_response_buffer, request_builder_to_conn)
- Implemented buffer limit setters (http_client_set_input_limit,
http_client_set_output_limit)
- Fully implemented request builder API (url, header, body, send)
- Implemented event processing with state machine approach
- Added connection reuse support via http_free_response
- Used consistent naming, formatting, and error handling patterns
- Renamed builder_to_conn to request_builder_to_conn to avoid
symbol conflicts with server.c during amalgamation
The implementation follows the same architecture as the server:
- Connection state machine for managing request/response lifecycle
- ByteQueue for input/output buffering
- Ready queue for completed responses
- Generation counters for builder validation
- Socket manager integration for async I/O