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:
@@ -804,6 +804,9 @@ typedef struct {
|
||||
// Data being sent to the server
|
||||
ByteQueue output;
|
||||
|
||||
// HTTP method for the request
|
||||
HTTP_Method method;
|
||||
|
||||
// Parsed URL for connection establishment
|
||||
HTTP_URL url;
|
||||
|
||||
@@ -874,9 +877,10 @@ typedef struct {
|
||||
int http_client_get_builder(HTTP_Client *client,
|
||||
HTTP_Response *response, HTTP_RequestBuilder *builder);
|
||||
|
||||
// Set the URL of the current request. This is the first
|
||||
// Set the method and URL of the current request. This is the first
|
||||
// function of the request builder that the user must call.
|
||||
void http_request_builder_url(HTTP_RequestBuilder builder, HTTP_String url);
|
||||
void http_request_builder_url(HTTP_RequestBuilder builder,
|
||||
HTTP_Method method, HTTP_String url);
|
||||
|
||||
// After the URL, the user may set zero or more headers.
|
||||
void http_request_builder_header(HTTP_RequestBuilder builder, HTTP_String str);
|
||||
|
||||
Reference in New Issue
Block a user