feat: enable keep-alive for internal routes by resetting connection state and handling pending reads
Reset multiple connection flags (content_type_checked, is_textual_content, response_headers_parsed, original_content_length, content_length_delta, patch_blocked) when reusing connection for internal route keep-alive. Add immediate handling of any buffered read data after state reset to prevent stale data blocking subsequent requests. Add comprehensive test verifying second request processing on internal dashboard route via Unix socket pair.
This commit is contained in:
@@ -1236,7 +1236,19 @@ static void handle_write_event(connection_t *conn) {
|
||||
memset(&conn->request, 0, sizeof(http_request_t));
|
||||
conn->request.keep_alive = 1;
|
||||
conn->state = CLIENT_STATE_READING_HEADERS;
|
||||
|
||||
conn->content_type_checked = 0;
|
||||
conn->is_textual_content = 0;
|
||||
conn->response_headers_parsed = 0;
|
||||
conn->original_content_length = 0;
|
||||
conn->content_length_delta = 0;
|
||||
conn->patch_blocked = 0;
|
||||
|
||||
connection_modify_epoll(conn->fd, EPOLLIN);
|
||||
|
||||
if (buffer_available_read(&conn->read_buf) > 0) {
|
||||
handle_client_read(conn);
|
||||
}
|
||||
} else {
|
||||
connection_modify_epoll(conn->fd, EPOLLIN);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user