From c76599f71c592c3f7ffcec759ec7f8c846f9baa1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 12 Feb 2023 12:21:14 +0100 Subject: [PATCH] transport: don't export new_reader The semantics are internal --- net/http/client.ha | 3 ++- net/http/transport.ha | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/net/http/client.ha b/net/http/client.ha index c88e54c..93d91b3 100644 --- a/net/http/client.ha +++ b/net/http/client.ha @@ -7,6 +7,7 @@ use strings; export type client = struct { default_header: header, + default_transport: transport, }; // Creates a new HTTP [[client]] with the provided User-Agent string, which is @@ -14,7 +15,7 @@ export type client = struct { // resourfces associated with the HTTP client after use. export fn newclient(ua: str) client = { let client = client { ... }; - client_add_header(&client, "User-Agent", ua); + header_add(&client, "User-Agent", ua); return client; }; diff --git a/net/http/transport.ha b/net/http/transport.ha index 7318aad..e71bc09 100644 --- a/net/http/transport.ha +++ b/net/http/transport.ha @@ -48,7 +48,7 @@ export type transport = struct { content: content_mode, }; -export fn new_reader( +fn new_reader( conn: io::handle, resp: *response, scan: *bufio::scanner, @@ -71,6 +71,12 @@ export fn new_reader( return new_identity_reader(conn, remain, length); }; + // TODO: Figure out the semantics for closing the stream + // The caller should probably be required to close it + // It should close/free any intermediate transport/content decoders + // And it should not close the actual connection if it's still in the + // connection pool + // Unless it isn't in the pool, then it should! let stream: io::handle = conn; let buffer: []u8 = bufio::scan_buffer(scan); const iter = strings::tokenize(te, ",");