1
Fork 0

Plumb transport config through to [[do]]

This commit is contained in:
Drew DeVault 2023-02-12 13:07:05 +01:00
parent c63af5d3ec
commit 5d39543fcf
2 changed files with 13 additions and 0 deletions

View file

@ -48,6 +48,7 @@ fn new_request(client: *client, method: str, target: *uri::uri) request = {
method = method, method = method,
target = alloc(uri::dup(target)), target = alloc(uri::dup(target)),
header = header_dup(&client.default_header), header = header_dup(&client.default_header),
transport = null,
body = void, body = void,
}; };
if (req.target.port == 0) { if (req.target.port == 0) {

View file

@ -33,6 +33,18 @@ export fn do(client: *client, req: *request) (response | error) = {
fmt::fprintf(&file, "\r\n")?; fmt::fprintf(&file, "\r\n")?;
bufio::flush(&file)?; 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) { match (req.body) {
case let body: io::handle => case let body: io::handle =>
io::copy(conn, body)?; io::copy(conn, body)?;