Address code review feedback for HTTP client and server

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.
This commit is contained in:
Claude
2025-11-21 20:37:18 +01:00
committed by cozis
parent 9868ae2e33
commit 51d3f84715
7 changed files with 77 additions and 33 deletions
+1 -1
View File
@@ -240,7 +240,7 @@ bool http_server_next_request(HTTP_Server *server,
if (server->num_ready == 0)
return false;
HTTP_ServerConn *conn = &server->conns[server->ready_head];
HTTP_ServerConn *conn = &server->conns[server->ready[server->ready_head]];
server->ready_head = (server->ready_head + 1) % HTTP_SERVER_CAPACITY;
server->num_ready--;