Add missing .clang-format, and fix some spaces that slipped through.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4856 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-02-17 19:22:02 +00:00
parent 1958623a7a
commit d0e11bc68b
23 changed files with 583 additions and 597 deletions

View File

@ -132,8 +132,7 @@ static bool _http_find_handler(tf_http_t* http, const char* path, tf_http_callba
for (int i = 0; i < http->handlers_count; i++)
{
if (!http->handlers[i].pattern || !*http->handlers[i].pattern || strcmp(path, http->handlers[i].pattern) == 0 ||
(*http->handlers[i].pattern && strncmp(path, http->handlers[i].pattern, strlen(http->handlers[i].pattern)) == 0 &&
path[strlen(http->handlers[i].pattern) - 1] == '/'))
(*http->handlers[i].pattern && strncmp(path, http->handlers[i].pattern, strlen(http->handlers[i].pattern)) == 0 && path[strlen(http->handlers[i].pattern) - 1] == '/'))
{
*out_callback = http->handlers[i].callback;
*out_trace_name = http->handlers[i].pattern;
@ -301,8 +300,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
size_t total_length = mask_start + 4 + length;
if (connection->body_length >= total_length)
{
uint32_t mask =
(uint32_t)p[mask_start + 0] | (uint32_t)p[mask_start + 1] << 8 | (uint32_t)p[mask_start + 2] << 16 | (uint32_t)p[mask_start + 3] << 24;
uint32_t mask = (uint32_t)p[mask_start + 0] | (uint32_t)p[mask_start + 1] << 8 | (uint32_t)p[mask_start + 2] << 16 | (uint32_t)p[mask_start + 3] << 24;
uint8_t* message = p + mask_start + 4;
_http_websocket_mask_in_place(message, mask, length);
@ -324,8 +322,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
{
tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "websocket");
connection->request->on_message(connection->request, connection->fragment_length ? connection->fragment_op_code : op_code,
connection->fragment_length ? connection->fragment : message,
connection->fragment_length ? connection->fragment_length : length);
connection->fragment_length ? connection->fragment : message, connection->fragment_length ? connection->fragment_length : length);
tf_trace_end(connection->http->trace);
}
connection->fragment_length = 0;
@ -397,7 +394,7 @@ static size_t _http_on_read_plain_internal(tf_http_connection_t* connection, con
size_t header_count = sizeof(connection->headers) / sizeof(*connection->headers);
int parse_result = phr_parse_request(connection->headers_buffer, connection->headers_buffer_length, &method, &method_length, &path, &path_length,
&connection->minor_version, connection->headers, &header_count, connection->parsed_length);
&connection->minor_version, connection->headers, &header_count, connection->parsed_length);
connection->parsed_length = connection->headers_buffer_length;
if (parse_result > 0)
{
@ -445,8 +442,7 @@ static size_t _http_on_read_plain_internal(tf_http_connection_t* connection, con
connection->body = tf_realloc(connection->body, connection->content_length);
}
if (!_http_find_handler(connection->http, connection->path, &connection->callback, &connection->trace_name, &connection->user_data) ||
!connection->callback)
if (!_http_find_handler(connection->http, connection->path, &connection->callback, &connection->trace_name, &connection->user_data) || !connection->callback)
{
connection->callback = _http_builtin_404_handler;
connection->trace_name = "404";