Skip to content

Commit

Permalink
Allow for large HTTP requests in stub mode
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jun 19, 2024
1 parent 17876f1 commit b7eaf0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions deps/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22885,22 +22885,26 @@ int ecs_http_server_request(
int32_t method_len = ecs_os_strlen(method);
int32_t req_len = ecs_os_strlen(req);
int32_t http_ver_len = ecs_os_strlen(http_ver);
char reqbuf[1024], *reqstr = reqbuf;

int32_t len = method_len + req_len + http_ver_len + 1;
if (method_len + req_len + http_ver_len >= 1024) {
ecs_err("HTTP request too long");
return -1;
reqstr = ecs_os_malloc(len + 1);
}

char reqstr[1024];
char *ptr = reqstr;
ecs_os_memcpy(ptr, method, method_len); ptr += method_len;
ptr[0] = ' '; ptr ++;
ecs_os_memcpy(ptr, req, req_len); ptr += req_len;
ecs_os_memcpy(ptr, http_ver, http_ver_len); ptr += http_ver_len;
ptr[0] = '\n';

return ecs_http_server_http_request(srv, reqstr, len, reply_out);
int result = ecs_http_server_http_request(srv, reqstr, len, reply_out);
if (reqbuf != reqstr) {
ecs_os_free(reqstr);
}

return result;
}

void* ecs_http_server_ctx(
Expand Down
Binary file modified etc/v4/flecs_explorer.wasm
Binary file not shown.

0 comments on commit b7eaf0a

Please sign in to comment.