From 5d39543fcfef9f7c54f94d074862d0120e2c085e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 12 Feb 2023 13:07:05 +0100 Subject: [PATCH] Plumb transport config through to [[do]] --- net/http/client.ha | 1 + net/http/do.ha | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/net/http/client.ha b/net/http/client.ha index bf2a4bd..4eac8ab 100644 --- a/net/http/client.ha +++ b/net/http/client.ha @@ -48,6 +48,7 @@ fn new_request(client: *client, method: str, target: *uri::uri) request = { method = method, target = alloc(uri::dup(target)), header = header_dup(&client.default_header), + transport = null, body = void, }; if (req.target.port == 0) { diff --git a/net/http/do.ha b/net/http/do.ha index 7720dcc..1d68da7 100644 --- a/net/http/do.ha +++ b/net/http/do.ha @@ -33,6 +33,18 @@ export fn do(client: *client, req: *request) (response | error) = { fmt::fprintf(&file, "\r\n")?; bufio::flush(&file)?; + const trans = match (req.transport) { + case let t: *transport => + yield t; + case => + yield &client.default_transport; + }; + // TODO: Implement None + assert(trans.request_transport == transport_mode::AUTO); + assert(trans.response_transport == transport_mode::AUTO); + assert(trans.request_content == content_mode::AUTO); + assert(trans.response_content == content_mode::AUTO); + match (req.body) { case let body: io::handle => io::copy(conn, body)?;