Treat the ?query string and body the same as httpd.js does. Now I can auth.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4691 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-12-23 19:52:59 +00:00
parent 38ab32dad9
commit 196ab66e14
3 changed files with 23 additions and 0 deletions

View File

@ -25,6 +25,7 @@ typedef struct _tf_http_connection_t
const char* method;
const char* path;
const char* query;
int minor_version;
char headers_buffer[8192];
@ -160,6 +161,7 @@ static void _http_reset_connection(tf_http_connection_t* connection)
connection->headers_buffer_length = 0;
connection->body_length = 0;
connection->content_length = 0;
connection->parsed_length = 0;
}
static void _http_add_body_bytes(tf_http_connection_t* connection, const void* data, size_t size)
@ -180,6 +182,9 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
.phase = k_http_callback_phase_headers_received,
.method = connection->method,
.path = connection->path,
.query = connection->query,
.body = connection->body,
.content_length = connection->content_length,
.headers = connection->headers,
.headers_count = connection->headers_length,
.user_data = connection->user_data,
@ -216,6 +221,12 @@ static void _http_on_read(uv_stream_t* stream, ssize_t read_size, const uv_buf_t
((char*)connection->method)[method_length] = '\0';
connection->path = path;
((char*)connection->path)[path_length] = '\0';
char* q = strchr(connection->path, '?');
if (q)
{
*q = '\0';
connection->query = q + 1;
}
connection->connection_close = connection->minor_version == 0;