From 337d063f15a7ef1f5e0fe8351748df755afb6da3 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 12 Feb 2023 13:14:19 +0100 Subject: [PATCH] Merge _set_content_length into new_request_body --- net/http/client.ha | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/http/client.ha b/net/http/client.ha index 853c639..fed803e 100644 --- a/net/http/client.ha +++ b/net/http/client.ha @@ -91,21 +91,18 @@ fn new_request_body( ) request = { let req = new_request(client, method, target); req.body = body; - request_set_content_length(&req, body); - return req; -}; -fn request_set_content_length(req: *request, body: io::handle) void = { - const prev = match (io::seek(body, 0, io::whence::CUR)) { + const offs = match (io::seek(body, 0, io::whence::CUR)) { case let off: io::off => yield off; case io::error => header_add(&req.header, "Transfer-Encoding", "chunked"); - return; + return req; }; const ln = io::seek(body, 0, io::whence::END)!; - io::seek(body, prev, io::whence::SET)!; + io::seek(body, offs, io::whence::SET)!; header_add(&req.header, "Content-Length", strconv::ztos(ln: size)); + return req; }; fn uri_origin_form(target: *uri::uri) uri::uri = {