From 859c8dc06e19b543fd4cc8ca2fb41b98542c50f0 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Feb 2023 10:27:06 +0100 Subject: [PATCH] net::http::do: place buffer on stack We can afford 4K of stack space --- net/http/do.ha | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/net/http/do.ha b/net/http/do.ha index 6b500d2..535deb0 100644 --- a/net/http/do.ha +++ b/net/http/do.ha @@ -9,18 +9,14 @@ use os; type context = struct { conn: io::handle, file: bufio::bufstream, - buf: []u8, + buf: [os::BUFSIZ]u8, }; // Performs an HTTP [[request]] with the given [[client]]. The request is // performed synchronously; this function blocks until the server has returned // the response status and all HTTP headers associated with the response. export fn do(client: *client, req: *request) (response | error) = { - let ctx = context { - buf = alloc([0...], os::BUFSIZ), - ... - }; - defer free(ctx.buf); + let ctx = context { ... }; assert(req.target.scheme == "http"); // TODO: https const conn = dial::dial_uri("tcp", req.target)?;