From c887db1b3d1be1e31f287da7edde92998d0a4db4 Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Wed, 6 Dec 2023 17:03:56 +0100 Subject: [PATCH] Update http deps --- .cargo/cargo-lock | 955 +++++++++++-------- crates/daqbuffer/Cargo.toml | 2 +- crates/daqbufp2/src/client.rs | 17 +- crates/err/Cargo.toml | 5 +- crates/err/src/lib.rs | 20 +- crates/httpclient/Cargo.toml | 12 +- crates/httpclient/src/httpclient.rs | 171 +++- crates/httpret/src/api1.rs | 99 +- crates/httpret/src/api4/binned.rs | 21 +- crates/httpret/src/api4/databuffer_tools.rs | 16 +- crates/httpret/src/api4/eventdata.rs | 32 +- crates/httpret/src/api4/events.rs | 35 +- crates/httpret/src/api4/search.rs | 23 +- crates/httpret/src/api4/status.rs | 18 +- crates/httpret/src/bodystream.rs | 33 +- crates/httpret/src/channel_status.rs | 37 +- crates/httpret/src/channelconfig.rs | 129 ++- crates/httpret/src/download.rs | 25 +- crates/httpret/src/gather.rs | 9 +- crates/httpret/src/httpret.rs | 140 +-- crates/httpret/src/proxy.rs | 161 ++-- crates/httpret/src/proxy/api1.rs | 44 +- crates/httpret/src/proxy/api1/reqstatus.rs | 37 +- crates/httpret/src/proxy/api4.rs | 44 +- crates/httpret/src/proxy/api4/caioclookup.rs | 26 +- crates/httpret/src/pulsemap.rs | 18 +- crates/httpret/src/settings.rs | 24 +- crates/streams/src/tcprawclient.rs | 24 +- 28 files changed, 1251 insertions(+), 926 deletions(-) diff --git a/.cargo/cargo-lock b/.cargo/cargo-lock index 1e81a90..67cd312 100644 --- a/.cargo/cargo-lock +++ b/.cargo/cargo-lock @@ -8,7 +8,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.28.0", + "gimli 0.28.1", ] [[package]] @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -68,36 +68,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -131,10 +131,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -154,25 +167,25 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "atomic-polyfill" -version = "0.1.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" dependencies = [ "critical-section", ] @@ -194,9 +207,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.11", + "http-body 0.4.5", + "hyper 0.14.27", "itoa", "matchit", "memchr", @@ -220,8 +233,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.11", + "http-body 0.4.5", "mime", "rustversion", "tower-layer", @@ -245,15 +258,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.13.1" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bigdecimal" @@ -283,9 +290,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitshuffle" @@ -346,9 +353,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -383,14 +390,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "clap" -version = "4.4.5" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -398,9 +405,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.5" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -410,21 +417,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cobs" @@ -442,7 +449,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" name = "commonio" version = "0.0.2" dependencies = [ - "async-channel", + "async-channel 1.9.0", "bytes", "chrono", "crc32fast", @@ -460,19 +467,20 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] [[package]] name = "console-api" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" +checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" dependencies = [ + "futures-core", "prost", "prost-types", "tonic", @@ -481,14 +489,14 @@ dependencies = [ [[package]] name = "console-subscriber" -version = "0.1.10" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4cf42660ac07fcebed809cfe561dd8730bcd35b075215e6479c516bcd0d11cb" +checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" dependencies = [ "console-api", "crossbeam-channel", "crossbeam-utils", - "futures", + "futures-task", "hdrhistogram", "humantime", "prost-types", @@ -505,9 +513,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -515,9 +523,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "corosensei" @@ -534,9 +542,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -683,7 +691,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset", "scopeguard", ] @@ -724,7 +732,7 @@ dependencies = [ [[package]] name = "daqbuffer" -version = "0.4.5-alpha.0" +version = "0.5.0-alpha.0" dependencies = [ "bytes", "chrono", @@ -733,8 +741,7 @@ dependencies = [ "disk", "err", "futures-util", - "http", - "hyper", + "httpclient", "netpod", "serde", "serde_derive", @@ -753,10 +760,10 @@ dependencies = [ "disk", "err", "futures-util", - "http", + "http 1.0.0", "httpclient", "httpret", - "hyper", + "hyper 1.0.1", "items_0", "items_2", "lazy_static", @@ -794,7 +801,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -805,7 +812,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -815,7 +822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "lock_api", "once_cell", "parking_lot_core", @@ -825,7 +832,7 @@ dependencies = [ name = "dbconn" version = "0.0.2" dependencies = [ - "async-channel", + "async-channel 1.9.0", "byteorder", "bytes", "chrono", @@ -844,9 +851,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +dependencies = [ + "powerfmt", +] [[package]] name = "derivative" @@ -875,7 +885,7 @@ name = "disk" version = "0.0.2" dependencies = [ "arrayref", - "async-channel", + "async-channel 1.9.0", "async-stream", "bitshuffle", "byteorder", @@ -888,9 +898,7 @@ dependencies = [ "fs2", "futures-util", "hex", - "http", "httpclient", - "hyper", "items_0", "items_2", "libc", @@ -934,6 +942,12 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "enum-iterator" version = "0.7.0" @@ -956,9 +970,9 @@ dependencies = [ [[package]] name = "enumset" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" +checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" dependencies = [ "enumset_derive", ] @@ -972,7 +986,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -995,10 +1009,12 @@ name = "err" version = "0.0.5" dependencies = [ "anyhow", - "async-channel", + "async-channel 1.9.0", + "async-channel 2.1.1", "backtrace", "chrono", - "http", + "http 1.0.0", + "hyper 1.0.1", "regex", "rmp-serde", "serde", @@ -1011,23 +1027,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -1036,6 +1041,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1056,9 +1082,9 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -1087,9 +1113,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1112,9 +1138,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1127,9 +1153,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1137,15 +1163,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -1154,38 +1180,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -1220,9 +1246,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -1242,23 +1268,42 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 1.9.3", + "http 0.2.11", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -1295,17 +1340,17 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hdrhistogram" -version = "7.5.2" +version = "7.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f19b9f54f7c7f55e31401bb647626ce0cf0f67b0004982ce815b3ee72a02aa8" +checksum = "765c9198f173dd59ce26ff9f95ef0aafd0a0fe01fb9d72841bc5066a4c06511d" dependencies = [ - "base64 0.13.1", + "base64", "byteorder", "flate2", "nom", @@ -1314,9 +1359,9 @@ dependencies = [ [[package]] name = "heapless" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", @@ -1370,9 +1415,20 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" dependencies = [ "bytes", "fnv", @@ -1386,7 +1442,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.11", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -1400,13 +1479,16 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" name = "httpclient" version = "0.0.2" dependencies = [ - "async-channel", + "async-channel 1.9.0", "bytes", "err", "futures-util", - "http", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.0.1", "hyper-tls", + "hyper-util", "netpod", "parse", "serde", @@ -1426,7 +1508,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" name = "httpret" version = "0.4.1" dependencies = [ - "async-channel", + "async-channel 1.9.0", "bytes", "chrono", "commonio", @@ -1434,12 +1516,14 @@ dependencies = [ "disk", "err", "futures-util", - "http", + "http 1.0.0", + "http-body-util", "httpclient", - "hyper", + "hyper 1.0.1", + "hyper-util", "items_0", "items_2", - "itertools 0.11.0", + "itertools", "md-5", "netpod", "nodenet", @@ -1482,27 +1566,47 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.22", + "http 0.2.11", + "http-body 0.4.5", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", + "want", +] + [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.27", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -1510,29 +1614,52 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper", + "http-body-util", + "hyper 1.0.1", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca339002caeb0d159cc6e023dff48e199f081e42fa039895c7c6f38b37f2e9d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.0.1", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1552,9 +1679,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1572,12 +1699,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -1625,16 +1752,7 @@ dependencies = [ name = "items_proc" version = "0.0.2" dependencies = [ - "syn 2.0.37", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", + "syn 2.0.39", ] [[package]] @@ -1654,9 +1772,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -1675,21 +1793,21 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1746,9 +1864,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -1768,15 +1886,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -1809,9 +1918,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", @@ -1846,7 +1955,7 @@ dependencies = [ name = "netpod" version = "0.0.2" dependencies = [ - "async-channel", + "async-channel 1.9.0", "bytes", "chrono", "err", @@ -1865,7 +1974,7 @@ name = "nodenet" version = "0.0.2" dependencies = [ "arrayref", - "async-channel", + "async-channel 1.9.0", "byteorder", "bytes", "chrono", @@ -1922,13 +2031,13 @@ dependencies = [ [[package]] name = "num-derive" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6a0fd4f737c707bd9086cc16c925f294943eb62eb71499e9fd4cf71f8b9f4e" +checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1943,9 +2052,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1978,7 +2087,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1998,11 +2107,11 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -2019,7 +2128,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -2030,9 +2139,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", @@ -2046,6 +2155,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "parking_lot" version = "0.12.1" @@ -2058,15 +2173,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2094,9 +2209,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" @@ -2133,7 +2248,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -2156,11 +2271,12 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "postcard" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d534c6e61df1c7166e636ca612d9820d486fe96ddad37f7abc671517b297488e" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" dependencies = [ "cobs", + "embedded-io", "heapless", "serde", ] @@ -2171,7 +2287,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" dependencies = [ - "base64 0.21.4", + "base64", "byteorder", "bytes", "fallible-iterator", @@ -2197,6 +2313,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2239,18 +2361,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", "prost-derive", @@ -2258,22 +2380,22 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "prost-types" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" dependencies = [ "prost", ] @@ -2390,9 +2512,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] @@ -2411,14 +2533,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.8", - "regex-syntax 0.7.5", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -2432,13 +2554,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] @@ -2449,9 +2571,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "region" @@ -2542,15 +2664,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.14" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2582,9 +2704,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scylla" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9aa2b618718b5d4873926cecb99fe181a3b8c52b4983e2b20d6d833bfa9c1b" +checksum = "8338911f1c2a7bf8ba4036997196e49e9eda8d4414af10548e9420e23a5dbd6f" dependencies = [ "arc-swap", "async-trait", @@ -2595,7 +2717,7 @@ dependencies = [ "dashmap", "futures", "histogram", - "itertools 0.11.0", + "itertools", "lz4_flex", "num-bigint", "num_enum", @@ -2605,10 +2727,10 @@ dependencies = [ "scylla-macros", "smallvec", "snap", - "socket2 0.5.4", + "socket2 0.5.5", "strum", "strum_macros", - "thiserror 1.0.49", + "thiserror 1.0.50", "tokio", "tracing", "uuid", @@ -2630,27 +2752,27 @@ dependencies = [ "num_enum", "scylla-macros", "snap", - "thiserror 1.0.49", + "thiserror 1.0.50", "tokio", "uuid", ] [[package]] name = "scylla-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d777dadbf7163d1524ea4f5a095146298d263a686febb96d022cf46d06df32" +checksum = "5757ded3dfb10967ca7d1ff1084d072d565b5e10b2b21c286d5335c245425a7e" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "scyllaconn" version = "0.0.1" dependencies = [ - "async-channel", + "async-channel 1.9.0", "err", "futures-util", "items_0", @@ -2691,21 +2813,21 @@ dependencies = [ [[package]] name = "self_cell" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c309e515543e67811222dbc9e3dd7e1056279b782e1dacffe4242b718734fb6" +checksum = "e388332cd64eb80cd595a00941baf513caffae8dce9cfd0467fc9c66397dade6" [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -2733,20 +2855,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2755,11 +2877,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.25" +version = "0.9.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" +checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", "itoa", "ryu", "serde", @@ -2779,9 +2901,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -2834,21 +2956,21 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "snap" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" +checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -2856,9 +2978,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2890,7 +3012,7 @@ name = "streams" version = "0.0.2" dependencies = [ "arrayref", - "async-channel", + "async-channel 1.9.0", "byteorder", "bytes", "chrono", @@ -2968,9 +3090,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -2991,9 +3113,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "taskrun" @@ -3008,14 +3130,15 @@ dependencies = [ "time", "tokio", "tracing", + "tracing-log", "tracing-subscriber", ] [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", @@ -3034,11 +3157,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ - "thiserror-impl 1.0.49", + "thiserror-impl 1.0.50", ] [[package]] @@ -3048,18 +3171,18 @@ source = "git+https://github.com/dominikwerder/thiserror.git#052df05c18b5f26b462 dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -3074,12 +3197,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -3126,9 +3250,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -3138,7 +3262,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -3156,13 +3280,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -3195,7 +3319,7 @@ dependencies = [ "postgres-protocol", "postgres-types", "rand", - "socket2 0.5.4", + "socket2 0.5.5", "tokio", "tokio-util", "whoami", @@ -3214,9 +3338,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3228,9 +3352,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" @@ -3238,27 +3362,26 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", "toml_datetime", "winnow", ] [[package]] name = "tonic" -version = "0.9.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ + "async-stream", "async-trait", "axum", - "base64 0.21.4", + "base64", "bytes", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.22", + "http 0.2.11", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-timeout", "percent-encoding", "pin-project", @@ -3305,11 +3428,11 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3317,20 +3440,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -3350,20 +3473,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -3435,9 +3558,9 @@ checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3452,9 +3575,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", ] @@ -3494,9 +3617,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3504,47 +3627,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-downcast" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" -dependencies = [ - "js-sys", - "once_cell", - "wasm-bindgen", - "wasm-bindgen-downcast-macros", -] - -[[package]] -name = "wasm-bindgen-downcast-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3552,28 +3652,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasmer" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7954f3bdeb6cc9b46ddfbab7d795fc6a249a79f51c102d95679390526cf43d8" +checksum = "ce45cc009177ca345a6d041f9062305ad467d15e7d41494f5b81ab46d62d7a58" dependencies = [ "bytes", "cfg-if", @@ -3586,9 +3686,8 @@ dependencies = [ "serde-wasm-bindgen", "shared-buffer", "target-lexicon", - "thiserror 1.0.49", + "thiserror 1.0.50", "wasm-bindgen", - "wasm-bindgen-downcast", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-derive", @@ -3599,9 +3698,9 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c72380ddff4d9710366527100183df6f943caab5b63adc7cac6d90bacdf4628" +checksum = "e044f6140c844602b920deb4526aea3cc9c0d7cf23f00730bb9b2034669f522a" dependencies = [ "backtrace", "bytes", @@ -3617,7 +3716,7 @@ dependencies = [ "self_cell", "shared-buffer", "smallvec", - "thiserror 1.0.49", + "thiserror 1.0.50", "wasmer-types", "wasmer-vm", "wasmparser", @@ -3626,9 +3725,9 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957adcc170f007bf26293c7cd95352c1e471d7bf4295a1dfda796702a79d9648" +checksum = "32ce02358eb44a149d791c1d6648fb7f8b2f99cd55e3c4eef0474653ec8cc889" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -3645,9 +3744,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cd92754ce26eec6136ae6282d96ca59632bd47237ecba82824de16e34b3ce6b" +checksum = "c782d80401edb08e1eba206733f7859db6c997fc5a7f5fb44edc3ecd801468f6" dependencies = [ "proc-macro-error", "proc-macro2", @@ -3657,9 +3756,9 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93ca35c9a184e7d561f496c5d6da835c8309a8f76fcca1384f5800127395735" +checksum = "fd09e80d4d74bb9fd0ce6c3c106b1ceba1a050f9948db9d9b78ae53c172d6157" dependencies = [ "bytecheck", "enum-iterator", @@ -3668,14 +3767,14 @@ dependencies = [ "more-asserts", "rkyv", "target-lexicon", - "thiserror 1.0.49", + "thiserror 1.0.50", ] [[package]] name = "wasmer-vm" -version = "4.2.0" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200ff711048c0a2cb045d4984a673a1edea18f1e14f024694a43f4951922998b" +checksum = "bdcd8a4fd36414a7b6a003dbfbd32393bce3e155d715dd877c05c1b7a41d224d" dependencies = [ "backtrace", "cc", @@ -3690,11 +3789,11 @@ dependencies = [ "lazy_static", "libc", "mach", - "memoffset 0.8.0", + "memoffset", "more-asserts", "region", "scopeguard", - "thiserror 1.0.49", + "thiserror 1.0.50", "wasmer-types", "winapi", ] @@ -3711,9 +3810,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -3752,12 +3851,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -3779,7 +3878,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -3788,21 +3896,42 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" @@ -3815,6 +3944,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.33.0" @@ -3827,6 +3962,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.33.0" @@ -3839,6 +3980,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" @@ -3851,12 +3998,24 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" @@ -3870,10 +4029,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "winnow" -version = "0.5.15" +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e87b8dfbe3baffbe687eef2e164e32286eff31a5ee16463ce03d991643ec94" dependencies = [ "memchr", ] diff --git a/crates/daqbuffer/Cargo.toml b/crates/daqbuffer/Cargo.toml index 2f50fb5..e118e22 100644 --- a/crates/daqbuffer/Cargo.toml +++ b/crates/daqbuffer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "daqbuffer" -version = "0.4.5-alpha.0" +version = "0.5.0-alpha.0" authors = ["Dominik Werder "] edition = "2021" diff --git a/crates/daqbufp2/src/client.rs b/crates/daqbufp2/src/client.rs index bb792d7..d1ebe80 100644 --- a/crates/daqbufp2/src/client.rs +++ b/crates/daqbufp2/src/client.rs @@ -1,11 +1,12 @@ use crate::err::ErrConv; -use bytes::Bytes; use chrono::DateTime; use chrono::Utc; use disk::streamlog::Streamlog; use err::Error; use futures_util::TryStreamExt; use http::StatusCode; +use http::Uri; +use httpclient::body_empty; use items_0::streamitem::StreamItem; use netpod::log::*; use netpod::query::CacheUsage; @@ -22,10 +23,12 @@ use url::Url; pub async fn status(host: String, port: u16) -> Result<(), Error> { let t1 = Utc::now(); let uri = format!("http://{}:{}/api/4/node_status", host, port,); - let req = hyper::Request::builder() + let uri: Uri = uri.parse()?; + let req = http::Request::builder() .method(http::Method::GET) + .header(http::header::HOST, uri.host().unwrap()) .uri(uri) - .body(httpclient::Full::new(Bytes::new()))?; + .body(body_empty())?; let mut client = httpclient::connect_client(req.uri()).await?; let res = client.send_request(req).await?; if res.status() != StatusCode::OK { @@ -69,11 +72,13 @@ pub async fn get_binned( let mut url = Url::parse(&format!("http://{}:{}/api/4/binned", hp.host, hp.port))?; query.append_to_url(&mut url); let url = url; - let req = hyper::Request::builder() + let uri: Uri = url.as_str().parse()?; + let req = http::Request::builder() .method(http::Method::GET) - .uri(url.to_string()) + .header(http::header::HOST, uri.host().unwrap()) .header(http::header::ACCEPT, APP_OCTET) - .body(httpclient::Full::new(Bytes::new())) + .uri(uri) + .body(body_empty()) .ec()?; let mut client = httpclient::connect_client(req.uri()).await?; let res = client.send_request(req).await?; diff --git a/crates/err/Cargo.toml b/crates/err/Cargo.toml index bb52edf..60c2485 100644 --- a/crates/err/Cargo.toml +++ b/crates/err/Cargo.toml @@ -18,9 +18,8 @@ async_channel_2 = { package = "async-channel", version = "2.0.0" } chrono = { version = "0.4.26", features = ["serde"] } url = "2.4.0" regex = "1.9.1" -http = "0.2.9" -http_1 = { package = "http", version = "1.0.0" } -hyper_1 = { package = "hyper", version = "1.0.1" } +http = "1.0.0" +hyper = "1.0.1" thiserror = "=0.0.1" anyhow = "1.0" tokio = "1" diff --git a/crates/err/src/lib.rs b/crates/err/src/lib.rs index 0ec420e..fa36b5b 100644 --- a/crates/err/src/lib.rs +++ b/crates/err/src/lib.rs @@ -429,12 +429,6 @@ impl From for Error { } } -impl From for Error { - fn from(k: http::header::ToStrError) -> Self { - Self::from_string(format!("{:?}", k)) - } -} - impl From for Error { fn from(k: anyhow::Error) -> Self { Self::from_string(format!("{k}")) @@ -447,14 +441,20 @@ impl From for Error { } } -impl From for Error { - fn from(k: http_1::Error) -> Self { +impl From for Error { + fn from(k: http::Error) -> Self { Self::from_string(k) } } -impl From for Error { - fn from(k: hyper_1::Error) -> Self { +impl From for Error { + fn from(k: http::uri::InvalidUri) -> Self { + Self::from_string(k) + } +} + +impl From for Error { + fn from(k: hyper::Error) -> Self { Self::from_string(k) } } diff --git a/crates/httpclient/Cargo.toml b/crates/httpclient/Cargo.toml index b8e5d62..91cd5d6 100644 --- a/crates/httpclient/Cargo.toml +++ b/crates/httpclient/Cargo.toml @@ -8,17 +8,17 @@ edition = "2021" futures-util = "0.3.25" serde = { version = "1.0.147", features = ["derive"] } serde_json = "1.0.89" -url = "2.3.1" -tokio = { version = "1.22.0", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] } -tracing = "0.1.37" +url = "2.5.0" +tokio = { version = "1.34.0", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] } +tracing = "0.1.40" http = "1.0.0" http-body = "1.0.0" http-body-util = "0.1.0" hyper = { version = "1.0.1", features = ["http1", "http2", "client", "server"] } -hyper-tls = { version = "0.5.0" } +hyper-tls = { version = "0.6.0" } hyper-util = { version = "0.1.1", features = ["full"] } -bytes = "1.3.0" -async-channel = "1.8.0" +bytes = "1.5.0" +async-channel = "1.9.0" err = { path = "../err" } netpod = { path = "../netpod" } parse = { path = "../parse" } diff --git a/crates/httpclient/src/httpclient.rs b/crates/httpclient/src/httpclient.rs index 9da8370..2fa13cc 100644 --- a/crates/httpclient/src/httpclient.rs +++ b/crates/httpclient/src/httpclient.rs @@ -1,18 +1,22 @@ -pub use hyper_util; - pub use http_body_util; pub use http_body_util::Full; +pub use hyper_util; +use bytes::BufMut; use bytes::Bytes; use bytes::BytesMut; -use err::PublicError; -use futures_util::pin_mut; +use futures_util::Stream; +use futures_util::StreamExt; +use futures_util::TryStreamExt; use http::header; use http::Request; use http::Response; use http::StatusCode; +use http_body::Frame; use http_body_util::combinators::BoxBody; +use http_body_util::BodyExt; use hyper::body::Body; +use hyper::body::Incoming; use hyper::client::conn::http2::SendRequest; use hyper::Method; use netpod::log::*; @@ -21,18 +25,150 @@ use netpod::ChannelConfigQuery; use netpod::ChannelConfigResponse; use netpod::NodeConfigCached; use netpod::APP_JSON; +use serde::Serialize; use std::fmt; use std::pin::Pin; use std::task::Context; use std::task::Poll; -use tokio::io; -use tokio::io::AsyncRead; -use tokio::io::ReadBuf; use tokio::net::TcpStream; use url::Url; pub type BodyBox = BoxBody; pub type RespBox = Response; +pub type Requ = Request; +pub type RespFull = Response>; + +// TODO rename: too similar. +pub type StreamBody = http_body_util::StreamBody, BodyError>> + Send>>>; +pub type StreamResponse = Response; + +fn _assert1() { + let body: Full = todoval(); + let _: &dyn Body = &body; +} + +fn _assert2() { + let stream: Pin, BodyError>>>> = todoval(); + let body = http_body_util::StreamBody::new(stream); + let _: &dyn Body = &body; +} + +#[allow(unused)] +fn todoval() -> T { + todo!() +} + +pub fn body_empty() -> StreamBody { + // Full::new(Bytes::new()).map_err(Into::into).boxed() + let fr = Frame::data(Bytes::new()); + let stream = futures_util::stream::iter([Ok(fr)]); + http_body_util::StreamBody::new(Box::pin(stream)) +} + +pub fn body_string(body: S) -> StreamBody { + // Full::new(Bytes::from(body.to_string())).map_err(Into::into).boxed() + let fr = Frame::data(Bytes::from(body.to_string())); + let stream = futures_util::stream::iter([Ok(fr)]); + http_body_util::StreamBody::new(Box::pin(stream)) +} + +pub fn body_bytes>(body: D) -> StreamBody { + let fr = Frame::data(body.into()); + let stream = futures_util::stream::iter([Ok(fr)]); + http_body_util::StreamBody::new(Box::pin(stream)) +} + +pub trait IntoBody { + fn into_body(self) -> StreamBody; +} + +pub struct StringBody { + body: String, +} + +impl From for StringBody { + fn from(value: S) -> Self { + Self { + body: value.to_string(), + } + } +} + +impl IntoBody for StringBody { + fn into_body(self) -> StreamBody { + let fr = Frame::data(Bytes::from(self.body.as_bytes().to_vec())); + let stream = futures_util::stream::iter([Ok(fr)]); + http_body_util::StreamBody::new(Box::pin(stream)) + } +} + +pub struct ToJsonBody { + body: Vec, +} + +impl From<&S> for ToJsonBody { + fn from(value: &S) -> Self { + Self { + body: serde_json::to_vec(value).unwrap_or(Vec::new()), + } + } +} + +impl IntoBody for ToJsonBody { + fn into_body(self) -> StreamBody { + let fr = Frame::data(Bytes::from(self.body)); + let stream = futures_util::stream::iter([Ok(fr)]); + http_body_util::StreamBody::new(Box::pin(stream)) + } +} + +pub fn body_stream(stream: S) -> StreamBody +where + S: Stream> + Send + 'static, + I: Into, + E: fmt::Display, +{ + let stream = stream.map(|x| match x { + Ok(x) => Ok(Frame::data(x.into())), + Err(_e) => Err(BodyError::Bad), + }); + StreamBody::new(Box::pin(stream)) +} + +pub struct StreamIncoming { + inp: http_body_util::BodyStream, +} + +impl StreamIncoming { + pub fn new(inp: Incoming) -> Self { + Self { + inp: http_body_util::BodyStream::new(inp), + } + } +} + +impl Stream for StreamIncoming { + type Item = Result; + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + use Poll::*; + match self.inp.poll_next_unpin(cx) { + Ready(Some(Ok(x))) => { + if x.is_data() { + Ready(Some(Ok(x.into_data().unwrap()))) + } else { + Ready(Some(Ok(Bytes::new()))) + } + } + Ready(Some(Err(e))) => { + error!("{e}"); + Ready(Some(Err(BodyError::Bad))) + } + Ready(None) => Ready(None), + Pending => Pending, + } + } +} #[derive(Debug)] pub enum BodyError { @@ -62,19 +198,19 @@ pub enum Error { } impl From for Error { - fn from(value: std::io::Error) -> Self { + fn from(_: std::io::Error) -> Self { Self::IO } } impl From for Error { - fn from(value: http::Error) -> Self { + fn from(_: http::Error) -> Self { Self::Http } } impl From for Error { - fn from(value: hyper::Error) -> Self { + fn from(_: hyper::Error) -> Self { Self::Http } } @@ -102,13 +238,11 @@ pub async fn http_get(url: Url, accept: &str) -> Result { .uri(url.to_string()) .header(header::HOST, url.host_str().ok_or_else(|| Error::BadUrl)?) .header(header::ACCEPT, accept) - .body(Full::new(Bytes::new()))?; + .body(body_empty())?; let mut send_req = connect_client(req.uri()).await?; let res = send_req.send_request(req).await?; let (head, mut body) = res.into_parts(); debug!("http_get head {head:?}"); - use bytes::BufMut; - use http_body_util::BodyExt; let mut buf = BytesMut::new(); while let Some(x) = body.frame().await { match x { @@ -128,14 +262,13 @@ pub async fn http_get(url: Url, accept: &str) -> Result { } pub async fn http_post(url: Url, accept: &str, body: String) -> Result { - let body = Bytes::from(body.as_bytes().to_vec()); let req = Request::builder() .method(http::Method::POST) .uri(url.to_string()) .header(header::HOST, url.host_str().ok_or_else(|| Error::BadUrl)?) .header(header::CONTENT_TYPE, APP_JSON) .header(header::ACCEPT, accept) - .body(Full::new(body))?; + .body(body_string(body))?; let mut send_req = connect_client(req.uri()).await?; let res = send_req.send_request(req).await?; if res.status() != StatusCode::OK { @@ -143,12 +276,12 @@ pub async fn http_post(url: Url, accept: &str, body: String) -> Result Result Result>, Error> { +pub async fn connect_client(uri: &http::Uri) -> Result, Error> { let host = uri.host().ok_or_else(|| Error::BadUrl)?; let port = uri.port_u16().ok_or_else(|| Error::BadUrl)?; let stream = TcpStream::connect(format!("{host}:{port}")).await?; @@ -178,8 +311,6 @@ pub async fn connect_client(uri: &http::Uri) -> Result>, } pub async fn read_body_bytes(mut body: hyper::body::Incoming) -> Result { - use bytes::BufMut; - use http_body_util::BodyExt; let mut buf = BytesMut::new(); while let Some(x) = body.frame().await { match x { diff --git a/crates/httpret/src/api1.rs b/crates/httpret/src/api1.rs index 5b48def..8a968f1 100644 --- a/crates/httpret/src/api1.rs +++ b/crates/httpret/src/api1.rs @@ -6,21 +6,23 @@ use crate::gather::SubRes; use crate::response; use crate::ReqCtx; use crate::Requ; -use crate::RespFull; use bytes::BufMut; -use bytes::Bytes; use bytes::BytesMut; use disk::merge::mergedblobsfromremotes::MergedBlobsFromRemotes; use futures_util::Stream; use futures_util::StreamExt; use http::header; use http::Method; +use http::Response; use http::StatusCode; -use http_body_util::Full; +use httpclient::body_stream; use httpclient::connect_client; use httpclient::read_body_bytes; +use httpclient::IntoBody; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; +use hyper::body::Incoming; use hyper::Request; -use hyper::Response; use items_0::streamitem::RangeCompletableItem; use items_0::streamitem::Sitemty; use items_0::streamitem::StreamItem; @@ -138,7 +140,7 @@ impl FromErrorCode for ChannelSearchResultItemV1 { #[derive(Debug, Serialize, Deserialize)] pub struct ChannelSearchResultV1(pub Vec); -pub async fn channel_search_list_v1(req: Requ, proxy_config: &ProxyConfig) -> Result { +pub async fn channel_search_list_v1(req: Requ, proxy_config: &ProxyConfig) -> Result { let (head, reqbody) = req.into_parts(); let bodybytes = read_body_bytes(reqbody).await?; let query: ChannelSearchQueryV1 = serde_json::from_slice(&bodybytes)?; @@ -168,9 +170,10 @@ pub async fn channel_search_list_v1(req: Requ, proxy_config: &ProxyConfig) -> Re a })?; let tags: Vec<_> = urls.iter().map(|k| k.to_string()).collect(); - let nt = |tag, res| { + let nt = |tag: String, res: Response| { let fut = async { - let body = read_body_bytes(res).await?; + let (_head, body) = res.into_parts(); + let body = read_body_bytes(body).await?; let res: ChannelSearchResult = match serde_json::from_slice(&body) { Ok(k) => k, Err(_) => ChannelSearchResult { channels: Vec::new() }, @@ -234,14 +237,14 @@ pub async fn channel_search_list_v1(req: Requ, proxy_config: &ProxyConfig) -> Re .await?; Ok(ret) } else { - Ok(response(StatusCode::NOT_ACCEPTABLE).body(Full::new(Bytes::new()))?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?) } } - None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(Full::new(Bytes::new()))?), + None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?), } } -pub async fn channel_search_configs_v1(req: Requ, proxy_config: &ProxyConfig) -> Result { +pub async fn channel_search_configs_v1(req: Requ, proxy_config: &ProxyConfig) -> Result { let (head, reqbody) = req.into_parts(); let bodybytes = read_body_bytes(reqbody).await?; let query: ChannelSearchQueryV1 = serde_json::from_slice(&bodybytes)?; @@ -267,17 +270,18 @@ pub async fn channel_search_configs_v1(req: Requ, proxy_config: &ProxyConfig) -> } Err(e) => Err(Error::with_msg(format!("parse error for: {:?} {:?}", sh, e))), }) - .fold_ok(vec![], |mut a, x| { + .fold_ok(Vec::new(), |mut a, x| { a.push(x); a })?; let tags: Vec<_> = urls.iter().map(|k| k.to_string()).collect(); - let nt = |tag, res| { + let nt = |tag: String, res: Response| { let fut = async { - let body = read_body_bytes(res).await?; + let (_head, body) = res.into_parts(); + let body = read_body_bytes(body).await?; let res: ChannelSearchResult = match serde_json::from_slice(&body) { Ok(k) => k, - Err(_) => ChannelSearchResult { channels: vec![] }, + Err(_) => ChannelSearchResult { channels: Vec::new() }, }; let ret = SubRes { tag, @@ -340,7 +344,7 @@ pub async fn channel_search_configs_v1(req: Requ, proxy_config: &ProxyConfig) -> } let res = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Full::new(serde_json::to_string(&res)?))?; + .body(ToJsonBody::from(&res).into_body())?; Ok(res) }; let bodies = (0..urls.len()).into_iter().map(|_| None).collect(); @@ -356,10 +360,10 @@ pub async fn channel_search_configs_v1(req: Requ, proxy_config: &ProxyConfig) -> .await?; Ok(ret) } else { - Ok(response(StatusCode::NOT_ACCEPTABLE).body(Full::new(Bytes::new()))?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?) } } - None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(Full::new(Bytes::new()))?), + None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?), } } @@ -420,7 +424,7 @@ impl FromErrorCode for ChannelBackendConfigsV1 { } // TODO replace usage of this by gather-generic -pub async fn gather_json_2_v1(req: Requ, pathpre: &str, _proxy_config: &ProxyConfig) -> Result { +pub async fn gather_json_2_v1(req: Requ, pathpre: &str, _proxy_config: &ProxyConfig) -> Result { let (part_head, part_body) = req.into_parts(); let bodyslice = read_body_bytes(part_body).await?; let gather_from: GatherFromV1 = serde_json::from_slice(&bodyslice)?; @@ -432,19 +436,19 @@ pub async fn gather_json_2_v1(req: Requ, pathpre: &str, _proxy_config: &ProxyCon let uri = format!("http://{}:{}/{}", gh.host, gh.port, path_post); let req = Request::builder() .method(Method::GET) - .uri(uri) - .header(header::HOST, gh.host); + .header(header::HOST, &gh.host) + .header(header::ACCEPT, APP_JSON) + .uri(uri); let req = if gh.inst.len() > 0 { req.header("retrieval_instance", &gh.inst) } else { req }; - let req = req.header(http::header::ACCEPT, APP_JSON); - let req = req.body(Full::new(Bytes::new())); + let req = req.body(body_empty())?; let task = tokio::spawn(async move { let mut client = connect_client(req.uri()).await?; let res = client.send_request(req).await?; - Ok::<_, Error>(process_answer(res?).await?) + Ok::<_, Error>(process_answer(res).await?) }); let task = tokio::time::timeout(std::time::Duration::from_millis(5000), task); spawned.push((gh.clone(), task)); @@ -474,7 +478,7 @@ pub async fn gather_json_2_v1(req: Requ, pathpre: &str, _proxy_config: &ProxyCon } let res = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(serde_json::to_string(&Jres { hosts: a })?.into())?; + .body(ToJsonBody::from(&Jres { hosts: a }).into_body())?; Ok(res) } @@ -490,24 +494,20 @@ struct GatherHostV1 { inst: String, } -async fn process_answer(res: RespFull) -> Result { - let (pre, mut body) = res.into_parts(); +async fn process_answer(res: Response) -> Result { + let (pre, body) = res.into_parts(); + let body = read_body_bytes(body).await?; + let body = String::from_utf8(body.to_vec())?; if pre.status != StatusCode::OK { - if let Some(c) = body.data().await { - let c: bytes::Bytes = c?; - let s1 = String::from_utf8(c.to_vec())?; - Ok(JsonValue::String(format!( - "status {} body {}", - pre.status.as_str(), - s1 - ))) - } else { - Ok(JsonValue::String(format!("status {}", pre.status.as_str()))) - } + Ok(JsonValue::String(format!( + "status {} body {}", + pre.status.as_str(), + body + ))) } else { - let val = match serde_json::from_slice(the_data) { + let val = match serde_json::from_str(&body) { Ok(k) => k, - Err(_e) => JsonValue::String(String::from_utf8(body_all.to_vec())?), + Err(_e) => JsonValue::String(body), }; Ok::<_, Error>(val) } @@ -850,7 +850,7 @@ impl Stream for DataApiPython3DataStream { #[allow(unused)] fn shape_to_api3proto(sh: &Option>) -> Vec { match sh { - None => vec![], + None => Vec::new(), Some(g) => { if g.len() == 1 { vec![g[0]] @@ -874,9 +874,14 @@ impl Api1EventsBinaryHandler { } } - pub async fn handle(&self, req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached) -> Result { + pub async fn handle( + &self, + req: Requ, + _ctx: &ReqCtx, + node_config: &NodeConfigCached, + ) -> Result { if req.method() != Method::POST { - return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Full::new(Bytes::new()))?); + return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?); } let (head, body) = req.into_parts(); let accept = head @@ -939,7 +944,7 @@ impl Api1EventsBinaryHandler { span: tracing::Span, reqidspan: tracing::Span, ncc: &NodeConfigCached, - ) -> Result { + ) -> Result { let self_name = any::type_name::(); // TODO this should go to usage statistics: debug!( @@ -1003,7 +1008,7 @@ impl Api1EventsBinaryHandler { ncc.clone(), ); let s = s.instrument(span).instrument(reqidspan); - let body = Body::wrap_stream(s); + let body = body_stream(s); let ret = response(StatusCode::OK).header(X_DAQBUF_REQID, reqctx.reqid()); let ret = ret.body(body)?; Ok(ret) @@ -1011,7 +1016,7 @@ impl Api1EventsBinaryHandler { // TODO set the public error code and message and return Err(e). let e = Error::with_public_msg_no_trace(format!("{self_name} unsupported Accept: {}", accept)); error!("{self_name} {e}"); - Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty)?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?) } } } @@ -1031,7 +1036,7 @@ impl RequestStatusHandler { } } - pub async fn handle(&self, req: Requ, _ncc: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, _ncc: &NodeConfigCached) -> Result { let (head, body) = req.into_parts(); if head.method != Method::GET { return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?); @@ -1053,7 +1058,7 @@ impl RequestStatusHandler { debug!("RequestStatusHandler status_id {:?}", status_id); let status = crate::status_board()?.status_as_json(status_id); let s = serde_json::to_string(&status)?; - let ret = response(StatusCode::OK).body(Full::new(s))?; + let ret = response(StatusCode::OK).body(body_string(s))?; Ok(ret) } } diff --git a/crates/httpret/src/api4/binned.rs b/crates/httpret/src/api4/binned.rs index 7feb272..b37845d 100644 --- a/crates/httpret/src/api4/binned.rs +++ b/crates/httpret/src/api4/binned.rs @@ -4,10 +4,12 @@ use crate::channelconfig::ch_conf_from_binned; use crate::err::Error; use crate::response_err; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::log::*; use netpod::timeunits::SEC; use netpod::FromUrl; @@ -16,7 +18,7 @@ use query::api4::binned::BinnedQuery; use tracing::Instrument; use url::Url; -async fn binned_json(url: Url, req: Request, node_config: &NodeConfigCached) -> Result, Error> { +async fn binned_json(url: Url, req: Requ, node_config: &NodeConfigCached) -> Result { debug!("{:?}", req); let reqid = crate::status_board() .map_err(|e| Error::with_msg_no_trace(e.to_string()))? @@ -45,12 +47,11 @@ async fn binned_json(url: Url, req: Request, node_config: &NodeConfigCache let item = streams::timebinnedjson::timebinned_json(query, ch_conf, reqid, node_config.node_config.cluster.clone()) .instrument(span1) .await?; - let buf = serde_json::to_vec(&item)?; - let ret = response(StatusCode::OK).body(Body::from(buf))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&item).into_body())?; Ok(ret) } -async fn binned(req: Request, node_config: &NodeConfigCached) -> Result, Error> { +async fn binned(req: Requ, node_config: &NodeConfigCached) -> Result { let url = { let s1 = format!("dummy:{}", req.uri()); Url::parse(&s1) @@ -83,7 +84,7 @@ async fn binned(req: Request, node_config: &NodeConfigCached) -> Result) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/binned" { Some(Self {}) } else { @@ -91,9 +92,9 @@ impl BinnedHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { - return Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?); + return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } match binned(req, node_config).await { Ok(ret) => Ok(ret), diff --git a/crates/httpret/src/api4/databuffer_tools.rs b/crates/httpret/src/api4/databuffer_tools.rs index 6a22d90..2309ef1 100644 --- a/crates/httpret/src/api4/databuffer_tools.rs +++ b/crates/httpret/src/api4/databuffer_tools.rs @@ -9,10 +9,12 @@ use err::ToPublicError; use futures_util::Stream; use futures_util::StreamExt; use http::Method; -use http::Request; use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::Requ; +use httpclient::StreamResponse; use netpod::log::*; use netpod::Node; use netpod::NodeConfigCached; @@ -54,7 +56,7 @@ impl ToPublicError for FindActiveError { pub struct FindActiveHandler {} impl FindActiveHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/tool/sfdatabuffer/find/channel/active" { Some(Self {}) } else { @@ -62,10 +64,10 @@ impl FindActiveHandler { } } - pub async fn handle(&self, req: Request, ncc: &NodeConfigCached) -> Result, FindActiveError> { + pub async fn handle(&self, req: Requ, ncc: &NodeConfigCached) -> Result { if req.method() != Method::GET { Ok(response(StatusCode::NOT_ACCEPTABLE) - .body(Body::empty()) + .body(body_empty()) .map_err(|_| FindActiveError::InternalError)?) } else { match Self::handle_req(req, ncc).await { @@ -80,7 +82,7 @@ impl FindActiveHandler { } } - async fn handle_req(req: Request, ncc: &NodeConfigCached) -> Result, FindActiveError> { + async fn handle_req(req: Requ, ncc: &NodeConfigCached) -> Result { let accept_def = APP_JSON; let accept = req .headers() @@ -108,7 +110,7 @@ impl FindActiveHandler { } }) .map(|x| Ok::<_, String>(Bytes::from(x))); - let body = Body::wrap_stream(Box::pin(stream)); + let body = body_stream(stream); Ok(Response::builder().status(StatusCode::OK).body(body).unwrap()) } else { Err(FindActiveError::HttpBadAccept) diff --git a/crates/httpret/src/api4/eventdata.rs b/crates/httpret/src/api4/eventdata.rs index 94dca28..7694384 100644 --- a/crates/httpret/src/api4/eventdata.rs +++ b/crates/httpret/src/api4/eventdata.rs @@ -4,12 +4,13 @@ use crate::ReqCtx; use err::thiserror; use err::ThisError; use err::ToPublicError; -use futures_util::TryStreamExt; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::read_body_bytes; +use httpclient::Requ; +use httpclient::StreamResponse; use netpod::log::*; use netpod::NodeConfigCached; use netpod::ServiceVersion; @@ -35,7 +36,7 @@ impl ToPublicError for EventDataError { pub struct EventDataHandler {} impl EventDataHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path().eq("/api/4/private/eventdata/frames") { Some(Self {}) } else { @@ -45,14 +46,14 @@ impl EventDataHandler { pub async fn handle( &self, - req: Request, + req: Requ, _ctx: &ReqCtx, ncc: &NodeConfigCached, _service_version: &ServiceVersion, - ) -> Result, EventDataError> { + ) -> Result { if req.method() != Method::POST { Ok(response(StatusCode::NOT_ACCEPTABLE) - .body(Body::empty()) + .body(body_empty()) .map_err(|_| EventDataError::InternalError)?) } else { match Self::handle_req(req, ncc).await { @@ -67,18 +68,21 @@ impl EventDataHandler { } } - async fn handle_req(req: Request, ncc: &NodeConfigCached) -> Result, EventDataError> { + async fn handle_req(req: Requ, ncc: &NodeConfigCached) -> Result { let (_head, body) = req.into_parts(); - let frames = - nodenet::conn::events_get_input_frames(body.map_err(|e| err::Error::with_msg_no_trace(e.to_string()))) - .await - .map_err(|_| EventDataError::InternalError)?; + let body = read_body_bytes(body) + .await + .map_err(|_e| EventDataError::InternalError)?; + let inp = futures_util::stream::iter([Ok(body)]); + let frames = nodenet::conn::events_get_input_frames(inp) + .await + .map_err(|_| EventDataError::InternalError)?; let (evsubq,) = nodenet::conn::events_parse_input_query(frames).map_err(|_| EventDataError::QueryParse)?; let stream = nodenet::conn::create_response_bytes_stream(evsubq, ncc) .await .map_err(|e| EventDataError::Error(Box::new(e)))?; let ret = response(StatusCode::OK) - .body(Body::wrap_stream(stream)) + .body(body_stream(stream)) .map_err(|_| EventDataError::InternalError)?; Ok(ret) } diff --git a/crates/httpret/src/api4/events.rs b/crates/httpret/src/api4/events.rs index 0a9fea6..a7d180d 100644 --- a/crates/httpret/src/api4/events.rs +++ b/crates/httpret/src/api4/events.rs @@ -6,10 +6,13 @@ use crate::ToPublicResponse; use futures_util::stream; use futures_util::TryStreamExt; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::log::*; use netpod::FromUrl; use netpod::NodeConfigCached; @@ -22,7 +25,7 @@ use url::Url; pub struct EventsHandler {} impl EventsHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/events" { Some(Self {}) } else { @@ -30,9 +33,9 @@ impl EventsHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { - return Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?); + return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } match plain_events(req, node_config).await { Ok(ret) => Ok(ret), @@ -44,7 +47,7 @@ impl EventsHandler { } } -async fn plain_events(req: Request, node_config: &NodeConfigCached) -> Result, Error> { +async fn plain_events(req: Requ, node_config: &NodeConfigCached) -> Result { let accept_def = APP_JSON; let accept = req .headers() @@ -66,25 +69,18 @@ async fn plain_events(req: Request, node_config: &NodeConfigCached) -> Res } } -async fn plain_events_binary( - url: Url, - req: Request, - node_config: &NodeConfigCached, -) -> Result, Error> { +async fn plain_events_binary(url: Url, req: Requ, node_config: &NodeConfigCached) -> Result { debug!("{:?}", req); let query = PlainEventsQuery::from_url(&url).map_err(|e| e.add_public_msg(format!("Can not understand query")))?; let ch_conf = chconf_from_events_quorum(&query, node_config).await?; info!("plain_events_binary chconf_from_events_quorum: {ch_conf:?}"); let s = stream::iter([Ok::<_, Error>(String::from("TODO_PREBINNED_BINARY_STREAM"))]); - let ret = response(StatusCode::OK).body(Body::wrap_stream(s.map_err(Error::from)))?; + let s = s.map_err(Error::from); + let ret = response(StatusCode::OK).body(body_stream(s))?; Ok(ret) } -async fn plain_events_json( - url: Url, - req: Request, - node_config: &NodeConfigCached, -) -> Result, Error> { +async fn plain_events_json(url: Url, req: Requ, node_config: &NodeConfigCached) -> Result { let reqid = crate::status_board()?.new_status_id(); info!("plain_events_json req: {:?}", req); let (_head, _body) = req.into_parts(); @@ -105,7 +101,6 @@ async fn plain_events_json( return Err(e.into()); } }; - let buf = serde_json::to_vec(&item)?; - let ret = response(StatusCode::OK).body(Body::from(buf))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&item).into_body())?; Ok(ret) } diff --git a/crates/httpret/src/api4/search.rs b/crates/httpret/src/api4/search.rs index 67e6a93..b8b3dab 100644 --- a/crates/httpret/src/api4/search.rs +++ b/crates/httpret/src/api4/search.rs @@ -2,10 +2,12 @@ use crate::bodystream::response; use crate::bodystream::ToPublicResponse; use crate::err::Error; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::log::*; use netpod::ChannelSearchQuery; use netpod::ChannelSearchResult; @@ -14,7 +16,7 @@ use netpod::ACCEPT_ALL; use netpod::APP_JSON; use url::Url; -pub async fn channel_search(req: Request, node_config: &NodeConfigCached) -> Result { +pub async fn channel_search(req: Requ, node_config: &NodeConfigCached) -> Result { let url = Url::parse(&format!("dummy://{}", req.uri()))?; let query = ChannelSearchQuery::from_url(&url)?; info!("search query: {:?}", query); @@ -25,7 +27,7 @@ pub async fn channel_search(req: Request, node_config: &NodeConfigCached) pub struct ChannelSearchHandler {} impl ChannelSearchHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/search/channel" { Some(Self {}) } else { @@ -33,7 +35,7 @@ impl ChannelSearchHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -42,20 +44,17 @@ impl ChannelSearchHandler { .map_or(accept_def, |k| k.to_str().unwrap_or(accept_def)); if accept.contains(APP_JSON) || accept.contains(ACCEPT_ALL) { match channel_search(req, node_config).await { - Ok(item) => { - let buf = serde_json::to_vec(&item)?; - Ok(response(StatusCode::OK).body(Body::from(buf))?) - } + Ok(item) => Ok(response(StatusCode::OK).body(ToJsonBody::from(&item).into_body())?), Err(e) => { warn!("handle: got error from channel_search: {e:?}"); Ok(e.to_public_response()) } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } } diff --git a/crates/httpret/src/api4/status.rs b/crates/httpret/src/api4/status.rs index 39cc504..d1a7f01 100644 --- a/crates/httpret/src/api4/status.rs +++ b/crates/httpret/src/api4/status.rs @@ -1,10 +1,11 @@ use crate::bodystream::response; use crate::err::Error; use crate::ReqCtx; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::log::*; use netpod::NodeConfigCached; use netpod::NodeStatus; @@ -28,7 +29,7 @@ impl StatusNodesRecursive { "/api/4/private/status/nodes/recursive" } - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == Self::path() { Some(Self {}) } else { @@ -38,11 +39,11 @@ impl StatusNodesRecursive { pub async fn handle( &self, - req: Request, + req: Requ, ctx: &ReqCtx, node_config: &NodeConfigCached, service_version: &ServiceVersion, - ) -> Result, Error> { + ) -> Result { let res = tokio::time::timeout( Duration::from_millis(1200), self.status(req, ctx, node_config, service_version), @@ -57,8 +58,7 @@ impl StatusNodesRecursive { }; match res { Ok(status) => { - let body = serde_json::to_vec(&status)?; - let ret = response(StatusCode::OK).body(Body::from(body))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&status).into_body())?; Ok(ret) } Err(e) => { @@ -71,7 +71,7 @@ impl StatusNodesRecursive { async fn status( &self, - req: Request, + req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, service_version: &ServiceVersion, diff --git a/crates/httpret/src/bodystream.rs b/crates/httpret/src/bodystream.rs index 329a9eb..c1e5386 100644 --- a/crates/httpret/src/bodystream.rs +++ b/crates/httpret/src/bodystream.rs @@ -1,13 +1,11 @@ use crate::err::Error; -use futures_util::StreamExt; -use http::HeaderMap; use http::Response; use http::StatusCode; +use httpclient::body_empty; +use httpclient::body_string; +use httpclient::StreamResponse; use netpod::log::*; use netpod::APP_JSON; -use std::pin::Pin; -use std::task::Context; -use std::task::Poll; pub fn response(status: T) -> http::response::Builder where @@ -18,17 +16,17 @@ where } pub trait ToPublicResponse { - fn to_public_response(&self) -> Response; + fn to_public_response(&self) -> StreamResponse; } impl ToPublicResponse for Error { - fn to_public_response(&self) -> Response { + fn to_public_response(&self) -> StreamResponse { self.0.to_public_response() } } impl ToPublicResponse for ::err::Error { - fn to_public_response(&self) -> Response { + fn to_public_response(&self) -> StreamResponse { use err::Reason; let e = self.to_public_error(); let status = match e.reason() { @@ -42,30 +40,15 @@ impl ToPublicResponse for ::err::Error { }; match response(status) .header(http::header::ACCEPT, APP_JSON) - .body(Body::from(msg)) + .body(body_string(msg)) { Ok(res) => res, Err(e) => { error!("can not generate http error response {e:?}"); - let mut res = Response::new(Body::default()); + let mut res = Response::new(body_empty()); *res.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; res } } } } - -struct BodyStreamWrap(netpod::BodyStream); - -// impl hyper::body::HttpBody for BodyStreamWrap { -// type Data = bytes::Bytes; -// type Error = ::err::Error; - -// fn poll_data(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll>> { -// self.0.inner.poll_next_unpin(cx) -// } - -// fn poll_trailers(self: Pin<&mut Self>, _cx: &mut Context) -> Poll, Self::Error>> { -// Poll::Ready(Ok(None)) -// } -// } diff --git a/crates/httpret/src/channel_status.rs b/crates/httpret/src/channel_status.rs index 20879c2..08b42b6 100644 --- a/crates/httpret/src/channel_status.rs +++ b/crates/httpret/src/channel_status.rs @@ -3,10 +3,13 @@ use crate::err::Error; use crate::ReqCtx; use futures_util::StreamExt; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::body_string; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use items_0::Empty; use items_0::Extendable; use items_2::channelevents::ChannelStatusEvents; @@ -22,7 +25,7 @@ use url::Url; pub struct ConnectionStatusEvents {} impl ConnectionStatusEvents { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/status/connection/events" { Some(Self {}) } else { @@ -32,10 +35,10 @@ impl ConnectionStatusEvents { pub async fn handle( &self, - req: Request, + req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, - ) -> Result, Error> { + ) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -47,20 +50,20 @@ impl ConnectionStatusEvents { let q = ChannelStateEventsQuery::from_url(&url)?; match self.fetch_data(&q, node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => { error!("{e}"); Ok(response(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from(format!("{:?}", e.public_msg())))?) + .body(body_string(format!("{:?}", e.public_msg())))?) } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -96,7 +99,7 @@ impl ConnectionStatusEvents { pub struct ChannelStatusEventsHandler {} impl ChannelStatusEventsHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/status/channel/events" { Some(Self {}) } else { @@ -106,10 +109,10 @@ impl ChannelStatusEventsHandler { pub async fn handle( &self, - req: Request, + req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, - ) -> Result, Error> { + ) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -121,20 +124,20 @@ impl ChannelStatusEventsHandler { let q = ChannelStateEventsQuery::from_url(&url)?; match self.fetch_data(&q, node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => { error!("{e}"); Ok(response(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from(format!("{:?}", e.public_msg())))?) + .body(body_string(format!("{:?}", e.public_msg())))?) } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } diff --git a/crates/httpret/src/channelconfig.rs b/crates/httpret/src/channelconfig.rs index fd8e219..dec04ea 100644 --- a/crates/httpret/src/channelconfig.rs +++ b/crates/httpret/src/channelconfig.rs @@ -4,10 +4,13 @@ use crate::ToPublicResponse; use dbconn::create_connection; use futures_util::StreamExt; use http::Method; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::body_empty; +use httpclient::body_string; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::get_url_query_pairs; use netpod::log::*; use netpod::query::prebinned::PreBinnedQuery; @@ -58,7 +61,7 @@ pub async fn ch_conf_from_binned( pub struct ChannelConfigHandler {} impl ChannelConfigHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channel/config" { Some(Self {}) } else { @@ -66,7 +69,7 @@ impl ChannelConfigHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -82,18 +85,14 @@ impl ChannelConfigHandler { } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } - async fn channel_config( - &self, - req: Request, - node_config: &NodeConfigCached, - ) -> Result, Error> { + async fn channel_config(&self, req: Requ, node_config: &NodeConfigCached) -> Result { let url = Url::parse(&format!("dummy:{}", req.uri()))?; let q = ChannelConfigQuery::from_url(&url)?; let conf = nodenet::channelconfig::channel_config(q.range.clone(), q.channel.clone(), node_config).await?; @@ -102,13 +101,13 @@ impl ChannelConfigHandler { let res: ChannelConfigResponse = conf.into(); let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::from(serde_json::to_string(&res)?))?; + .body(ToJsonBody::from(&res).into_body())?; Ok(ret) } None => { let ret = response(StatusCode::NOT_FOUND) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::empty())?; + .body(body_empty())?; Ok(ret) } } @@ -118,7 +117,7 @@ impl ChannelConfigHandler { pub struct ChannelConfigsHandler {} impl ChannelConfigsHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channel/configs" { Some(Self {}) } else { @@ -126,7 +125,7 @@ impl ChannelConfigsHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -142,14 +141,14 @@ impl ChannelConfigsHandler { } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } - async fn channel_configs(&self, req: Request, ncc: &NodeConfigCached) -> Result, Error> { + async fn channel_configs(&self, req: Requ, ncc: &NodeConfigCached) -> Result { info!("channel_configs"); let url = Url::parse(&format!("dummy:{}", req.uri()))?; let q = ChannelConfigQuery::from_url(&url)?; @@ -157,7 +156,7 @@ impl ChannelConfigsHandler { let ch_confs = nodenet::channelconfig::channel_configs(q.channel, ncc).await?; let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::from(serde_json::to_string(&ch_confs)?))?; + .body(ToJsonBody::from(&ch_confs).into_body())?; Ok(ret) } } @@ -165,7 +164,7 @@ impl ChannelConfigsHandler { pub struct ChannelConfigQuorumHandler {} impl ChannelConfigQuorumHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channel/config/quorum" { Some(Self {}) } else { @@ -173,7 +172,7 @@ impl ChannelConfigQuorumHandler { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -189,14 +188,14 @@ impl ChannelConfigQuorumHandler { } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } - async fn channel_config_quorum(&self, req: Request, ncc: &NodeConfigCached) -> Result, Error> { + async fn channel_config_quorum(&self, req: Requ, ncc: &NodeConfigCached) -> Result { info!("channel_config_quorum"); let url = Url::parse(&format!("dummy:{}", req.uri()))?; let q = ChannelConfigQuery::from_url(&url)?; @@ -204,7 +203,7 @@ impl ChannelConfigQuorumHandler { let ch_confs = nodenet::configquorum::find_config_basics_quorum(q.channel, q.range.into(), ncc).await?; let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::from(serde_json::to_string(&ch_confs)?))?; + .body(ToJsonBody::from(&ch_confs).into_body())?; Ok(ret) } } @@ -217,7 +216,7 @@ pub struct ConfigsHisto { pub struct ScyllaConfigsHisto {} impl ScyllaConfigsHisto { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/scylla/configs/histo" { Some(Self {}) } else { @@ -225,7 +224,7 @@ impl ScyllaConfigsHisto { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -236,13 +235,13 @@ impl ScyllaConfigsHisto { let res = self .make_histo(&node_config.node_config.cluster.backend, node_config) .await?; - let body = Body::from(serde_json::to_vec(&res)?); + let body = ToJsonBody::from(&res).into_body(); Ok(response(StatusCode::OK).body(body)?) } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -325,7 +324,7 @@ pub struct ChannelListWithType { pub struct ScyllaChannelsWithType {} impl ScyllaChannelsWithType { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/scylla/channels/with_type" { Some(Self {}) } else { @@ -333,7 +332,7 @@ impl ScyllaChannelsWithType { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -346,13 +345,13 @@ impl ScyllaChannelsWithType { let res = self .get_channels(&q, &node_config.node_config.cluster.backend, node_config) .await?; - let body = Body::from(serde_json::to_vec(&res)?); + let body = ToJsonBody::from(&res).into_body(); Ok(response(StatusCode::OK).body(body)?) } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -483,7 +482,7 @@ impl FromUrl for ScyllaChannelsActiveQuery { pub struct ScyllaChannelsActive {} impl ScyllaChannelsActive { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channels/active" { Some(Self {}) } else { @@ -491,7 +490,7 @@ impl ScyllaChannelsActive { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -502,13 +501,13 @@ impl ScyllaChannelsActive { let url = Url::parse(&format!("dummy:{}", req.uri()))?; let q = ScyllaChannelsActiveQuery::from_url(&url)?; let res = self.get_channels(&q, node_config).await?; - let body = Body::from(serde_json::to_vec(&res)?); + let body = ToJsonBody::from(&res).into_body(); Ok(response(StatusCode::OK).body(body)?) } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -586,7 +585,7 @@ pub struct IocForChannelRes { pub struct IocForChannel {} impl IocForChannel { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channel/ioc" { Some(Self {}) } else { @@ -594,7 +593,7 @@ impl IocForChannel { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -606,19 +605,19 @@ impl IocForChannel { let q = IocForChannelQuery::from_url(&url)?; match self.find(&q, node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => { - let body = Body::from(format!("{:?}", e.public_msg())); + let body = body_string(format!("{:?}", e.public_msg())); Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(body)?) } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -675,7 +674,7 @@ pub struct ScyllaSeriesTsMspResponse { pub struct ScyllaSeriesTsMsp {} impl ScyllaSeriesTsMsp { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/scylla/series/tsMsps" { Some(Self {}) } else { @@ -683,7 +682,7 @@ impl ScyllaSeriesTsMsp { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -695,17 +694,17 @@ impl ScyllaSeriesTsMsp { let q = ScyllaSeriesTsMspQuery::from_url(&url)?; match self.get_ts_msps(&q, node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => Ok(response(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from(format!("{:?}", e.public_msg())))?), + .body(body_string(format!("{:?}", e.public_msg())))?), } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -752,7 +751,7 @@ pub struct AmbigiousChannelNamesResponse { pub struct AmbigiousChannelNames {} impl AmbigiousChannelNames { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/channels/ambigious" { Some(Self {}) } else { @@ -760,7 +759,7 @@ impl AmbigiousChannelNames { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -770,17 +769,17 @@ impl AmbigiousChannelNames { if accept == APP_JSON || accept == ACCEPT_ALL { match self.process(node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => Ok(response(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from(format!("{:?}", e.public_msg())))?), + .body(body_string(format!("{:?}", e.public_msg())))?), } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -848,7 +847,7 @@ fn test_data_f64_01() -> (Msps, Lsps, Pulses, ValsF64) { pub struct GenerateScyllaTestData {} impl GenerateScyllaTestData { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/test/generate/scylla" { Some(Self {}) } else { @@ -856,7 +855,7 @@ impl GenerateScyllaTestData { } } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -866,17 +865,17 @@ impl GenerateScyllaTestData { if accept == APP_JSON || accept == ACCEPT_ALL { match self.process(node_config).await { Ok(k) => { - let body = Body::from(serde_json::to_vec(&k)?); + let body = ToJsonBody::from(&k).into_body(); Ok(response(StatusCode::OK).body(body)?) } Err(e) => Ok(response(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from(format!("{:?}", e.public_msg())))?), + .body(body_string(format!("{:?}", e.public_msg())))?), } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } diff --git a/crates/httpret/src/download.rs b/crates/httpret/src/download.rs index e6a3d51..e72d73e 100644 --- a/crates/httpret/src/download.rs +++ b/crates/httpret/src/download.rs @@ -2,17 +2,11 @@ use crate::body_empty; use crate::err::Error; use crate::response; use crate::Requ; -use crate::RespFull; -use crate::StreamBody; -use bytes::Bytes; -use futures_util::Stream; use futures_util::TryStreamExt; use http::Method; -use http::Response; use http::StatusCode; -use http_body_util::BodyExt; -use httpclient::httpclient::http_body_util; -use httpclient::RespBox; +use httpclient::body_stream; +use httpclient::StreamResponse; use netpod::get_url_query_pairs; use netpod::log::*; use netpod::DiskIoTune; @@ -72,7 +66,7 @@ impl DownloadHandler { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { self.get(req, node_config).await } else { @@ -80,7 +74,7 @@ impl DownloadHandler { } } - pub async fn get(&self, req: Requ, ncc: &NodeConfigCached) -> Result { + pub async fn get(&self, req: Requ, ncc: &NodeConfigCached) -> Result { let (head, _body) = req.into_parts(); let p2 = &head.uri.path()[Self::path_prefix().len()..]; let base = match &ncc.node.sf_databuffer { @@ -95,16 +89,7 @@ impl DownloadHandler { let file = tokio::fs::OpenOptions::new().read(true).open(&pp).await?; let stream = disk::file_content_stream(pp, file, query.disk_io_tune.clone(), "download").map_ok(|x| x.into_buf()); - - use futures_util::StreamExt; - use hyper::body::Frame; - let stream = stream.map(|item| item.map(|x| Frame::data(x.freeze()))); - let body = httpclient::httpclient::http_body_util::StreamBody::new(stream); - let body = BodyExt::boxed(body); - // let body = http_body_util::combinators::BoxBody::new(body); - // let body: StreamBody = Box::pin(body); - // let body: Pin, err::Error>>>> = Box::pin(body); - let res = response(StatusCode::OK).body(body)?; + let res = response(StatusCode::OK).body(body_stream(stream))?; Ok(res) } } diff --git a/crates/httpret/src/gather.rs b/crates/httpret/src/gather.rs index 40f8f54..4deac8d 100644 --- a/crates/httpret/src/gather.rs +++ b/crates/httpret/src/gather.rs @@ -3,13 +3,15 @@ use crate::body_string; use crate::err::Error; use crate::response; use crate::Requ; -use crate::RespFull; use futures_util::select; use futures_util::FutureExt; use http::Method; use http::StatusCode; use httpclient::connect_client; use httpclient::read_body_bytes; +use httpclient::IntoBody; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use hyper::body::Incoming; use hyper::Request; use hyper::Response; @@ -55,7 +57,7 @@ async fn process_answer(res: Response) -> Result Result { +pub async fn gather_get_json(req: Requ, node_config: &NodeConfigCached) -> Result { let (head, body) = req.into_parts(); let _bodyslice = read_body_bytes(body).await?; let pathpre = "/api/4/gather/"; @@ -68,6 +70,7 @@ pub async fn gather_get_json(req: Requ, node_config: &NodeConfigCached) -> Resul .filter_map(|node| { let uri = format!("http://{}:{}/api/4/{}", node.host, node.port, pathsuf); let req = Request::builder().method(Method::GET).uri(uri); + let req = req.header(http::header::HOST, &node.host); let req = req.header(http::header::ACCEPT, APP_JSON); match req.body(body_empty()) { Ok(req) => { @@ -123,7 +126,7 @@ pub async fn gather_get_json(req: Requ, node_config: &NodeConfigCached) -> Resul let a = a; let res = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(serde_json::to_string(&Jres { hosts: a })?.into())?; + .body(ToJsonBody::from(&Jres { hosts: a }).into_body())?; Ok(res) } diff --git a/crates/httpret/src/httpret.rs b/crates/httpret/src/httpret.rs index 45fb225..5dfdd69 100644 --- a/crates/httpret/src/httpret.rs +++ b/crates/httpret/src/httpret.rs @@ -25,12 +25,16 @@ use futures_util::FutureExt; use futures_util::StreamExt; use http::Method; use http::StatusCode; -use http_body_util::combinators::BoxBody; -use http_body_util::Full; -use hyper::body::Incoming; +use httpclient::body_bytes; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::body_string; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use hyper::service::service_fn; use hyper::Request; -use hyper::Response; use hyper_util::rt::TokioIo; use net::SocketAddr; use netpod::log::*; @@ -123,23 +127,6 @@ pub fn accepts_octets(hm: &http::HeaderMap) -> bool { } } -pub type Requ = Request; -pub type RespFull = Response>; - -use http_body_util::BodyExt; -use httpclient::BodyBox; -use httpclient::RespBox; - -pub fn body_empty() -> BodyBox { - Full::new(Bytes::new()).map_err(Into::into).boxed() -} - -pub fn body_string(body: S) -> BodyBox { - Full::new(Bytes::from(body.to_string())).map_err(Into::into).boxed() -} - -pub type StreamBody = Pin, ::err::Error>>>>; - pub async fn host(node_config: NodeConfigCached, service_version: ServiceVersion) -> Result<(), RetrievalError> { static STATUS_BOARD_INIT: Once = Once::new(); STATUS_BOARD_INIT.call_once(|| { @@ -158,7 +145,11 @@ pub async fn host(node_config: NodeConfigCached, service_version: ServiceVersion let listener = TcpListener::bind(bind_addr).await?; loop { - let (stream, addr) = listener.accept().await?; + let (stream, addr) = if let Ok(x) = listener.accept().await { + x + } else { + break; + }; debug!("new connection from {addr}"); let node_config = node_config.clone(); let service_version = service_version.clone(); @@ -188,7 +179,7 @@ async fn the_service_fn( addr: SocketAddr, node_config: NodeConfigCached, service_version: ServiceVersion, -) -> Result, Error> { +) -> Result { info!( "http-request {:?} - {:?} - {:?} - {:?}", addr, @@ -205,7 +196,7 @@ async fn http_service( req: Requ, node_config: NodeConfigCached, service_version: ServiceVersion, -) -> Result, Error> { +) -> Result { match http_service_try(req, &node_config, &service_version).await { Ok(k) => Ok(k), Err(e) => { @@ -282,7 +273,7 @@ impl ReqCtx { } // TODO remove because I want error bodies to be json. -pub fn response_err(status: StatusCode, msg: T) -> Result +pub fn response_err(status: StatusCode, msg: T) -> Result where T: AsRef, { @@ -295,7 +286,7 @@ where ), msg.as_ref() ); - let ret = response(status).body(Full::new(msg))?; + let ret = response(status).body(body_string(msg))?; Ok(ret) } @@ -305,7 +296,7 @@ macro_rules! static_http { let c = include_bytes!(concat!("../static/documentation/", $tgtex)); let ret = response(StatusCode::OK) .header("content-type", $ctype) - .body(Full::new(&c[..]))?; + .body(body_bytes(c.to_vec()))?; return Ok(ret); } }; @@ -314,7 +305,7 @@ macro_rules! static_http { let c = include_bytes!(concat!("../static/documentation/", $tgt)); let ret = response(StatusCode::OK) .header("content-type", $ctype) - .body(Full::new(&c[..]))?; + .body(body_bytes(c.to_vec()))?; return Ok(ret); } }; @@ -326,7 +317,7 @@ macro_rules! static_http_api1 { let c = include_bytes!(concat!("../static/documentation/", $tgtex)); let ret = response(StatusCode::OK) .header("content-type", $ctype) - .body(Full::new(&c[..]))?; + .body(body_bytes(c.to_vec()))?; return Ok(ret); } }; @@ -335,7 +326,7 @@ macro_rules! static_http_api1 { let c = include_bytes!(concat!("../static/documentation/", $tgt)); let ret = response(StatusCode::OK) .header("content-type", $ctype) - .body(Full::new(&c[..]))?; + .body(body_bytes(c.to_vec()))?; return Ok(ret); } }; @@ -345,7 +336,7 @@ async fn http_service_try( req: Requ, node_config: &NodeConfigCached, service_version: &ServiceVersion, -) -> Result { +) -> Result { use http::HeaderValue; let mut urlmarks = Vec::new(); urlmarks.push(format!("{}:{}", req.method(), req.uri())); @@ -376,7 +367,7 @@ async fn http_service_inner( ctx: &ReqCtx, node_config: &NodeConfigCached, service_version: &ServiceVersion, -) -> Result { +) -> Result { let uri = req.uri().clone(); let path = uri.path(); if path == "/api/4/private/version" { @@ -388,7 +379,7 @@ async fn http_service_inner( "patch": service_version.patch, }, }); - Ok(response(StatusCode::OK).body(body_string(serde_json::to_string(&ret)?))?) + Ok(response(StatusCode::OK).body(ToJsonBody::from(&ret).into_body())?) } else { Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } @@ -529,13 +520,13 @@ async fn http_service_inner( if req.method() == Method::GET { api_1_docs(path) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Full::new(Bytes::new()))?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } else if path.starts_with("/api/4/documentation/") { if req.method() == Method::GET { api_4_docs(path) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Full::new(Bytes::new()))?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } else { use std::fmt::Write; @@ -556,7 +547,7 @@ async fn http_service_inner( } } -pub fn api_4_docs(path: &str) -> Result { +pub fn api_4_docs(path: &str) -> Result { static_http!(path, "", "api4.html", "text/html"); static_http!(path, "style.css", "text/css"); static_http!(path, "script.js", "text/javascript"); @@ -564,7 +555,7 @@ pub fn api_4_docs(path: &str) -> Result { Ok(response(StatusCode::NOT_FOUND).body(body_empty())?) } -pub fn api_1_docs(path: &str) -> Result { +pub fn api_1_docs(path: &str) -> Result { static_http_api1!(path, "", "api1.html", "text/html"); static_http_api1!(path, "style.css", "text/css"); static_http_api1!(path, "script.js", "text/javascript"); @@ -582,7 +573,7 @@ impl StatusBoardAllHandler { } } - pub async fn handle(&self, _req: Requ, _node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, _req: Requ, _node_config: &NodeConfigCached) -> Result { use std::ops::Deref; let sb = status_board().unwrap(); let buf = serde_json::to_string(sb.deref()).unwrap(); @@ -591,7 +582,7 @@ impl StatusBoardAllHandler { } } -async fn prebinned(req: Requ, ctx: &ReqCtx, node_config: &NodeConfigCached) -> Result { +async fn prebinned(req: Requ, ctx: &ReqCtx, node_config: &NodeConfigCached) -> Result { match prebinned_inner(req, ctx, node_config).await { Ok(ret) => Ok(ret), Err(e) => { @@ -601,7 +592,11 @@ async fn prebinned(req: Requ, ctx: &ReqCtx, node_config: &NodeConfigCached) -> R } } -async fn prebinned_inner(req: Requ, _ctx: &ReqCtx, _node_config: &NodeConfigCached) -> Result { +async fn prebinned_inner( + req: Requ, + _ctx: &ReqCtx, + _node_config: &NodeConfigCached, +) -> Result { let (head, _body) = req.into_parts(); let url: url::Url = format!("dummy://{}", head.uri).parse()?; let query = PreBinnedQuery::from_url(&url)?; @@ -614,14 +609,22 @@ async fn prebinned_inner(req: Requ, _ctx: &ReqCtx, _node_config: &NodeConfigCach todo!() } -async fn random_channel(req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached) -> Result { +async fn random_channel( + req: Requ, + _ctx: &ReqCtx, + node_config: &NodeConfigCached, +) -> Result { let (_head, _body) = req.into_parts(); let ret = dbconn::random_channel(node_config).await?; let ret = response(StatusCode::OK).body(body_string(ret))?; Ok(ret) } -async fn clear_cache_all(req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached) -> Result { +async fn clear_cache_all( + req: Requ, + _ctx: &ReqCtx, + node_config: &NodeConfigCached, +) -> Result { let (head, _body) = req.into_parts(); let dry = match head.uri.query() { Some(q) => q.contains("dry"), @@ -638,7 +641,7 @@ async fn update_db_with_channel_names( req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, -) -> Result { +) -> Result { info!("httpret::update_db_with_channel_names"); let (head, _body) = req.into_parts(); let _dry = match head.uri.query() { @@ -650,15 +653,16 @@ async fn update_db_with_channel_names( .await; match res { Ok(res) => { + let stream = res.map(|k| match serde_json::to_string(&k) { + Ok(mut item) => { + item.push('\n'); + Ok(Bytes::from(item)) + } + Err(e) => Err(e), + }); let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON_LINES) - .body(Body::wrap_stream(res.map(|k| match serde_json::to_string(&k) { - Ok(mut item) => { - item.push('\n'); - Ok(item) - } - Err(e) => Err(e), - })))?; + .body(body_stream(stream))?; Ok(ret) } Err(e) => { @@ -676,22 +680,23 @@ async fn update_db_with_channel_names_3( req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, -) -> Result { +) -> Result { let (head, _body) = req.into_parts(); let _dry = match head.uri.query() { Some(q) => q.contains("dry"), None => false, }; let res = dbconn::scan::update_db_with_channel_names_3(node_config); + let stream = res.map(|k| match serde_json::to_string(&k) { + Ok(mut item) => { + item.push('\n'); + Ok(Bytes::from(item)) + } + Err(e) => Err(e), + }); let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON_LINES) - .body(Body::wrap_stream(res.map(|k| match serde_json::to_string(&k) { - Ok(mut item) => { - item.push('\n'); - Ok(item) - } - Err(e) => Err(e), - })))?; + .body(body_stream(stream))?; Ok(ret) } @@ -699,22 +704,23 @@ async fn update_db_with_all_channel_configs( req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, -) -> Result { +) -> Result { let (head, _body) = req.into_parts(); let _dry = match head.uri.query() { Some(q) => q.contains("dry"), None => false, }; let res = dbconn::scan::update_db_with_all_channel_configs(node_config.clone()).await?; + let stream = res.map(|k| match serde_json::to_string(&k) { + Ok(mut item) => { + item.push('\n'); + Ok(Bytes::from(item)) + } + Err(e) => Err(e), + }); let ret = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON_LINES) - .body(Body::wrap_stream(res.map(|k| match serde_json::to_string(&k) { - Ok(mut item) => { - item.push('\n'); - Ok(item) - } - Err(e) => Err(e), - })))?; + .body(body_stream(stream))?; Ok(ret) } @@ -722,7 +728,7 @@ async fn update_search_cache( req: Requ, _ctx: &ReqCtx, node_config: &NodeConfigCached, -) -> Result { +) -> Result { let (head, _body) = req.into_parts(); let _dry = match head.uri.query() { Some(q) => q.contains("dry"), diff --git a/crates/httpret/src/proxy.rs b/crates/httpret/src/proxy.rs index 98d7fd1..0446e24 100644 --- a/crates/httpret/src/proxy.rs +++ b/crates/httpret/src/proxy.rs @@ -19,12 +19,17 @@ use futures_util::pin_mut; use futures_util::Stream; use http::Method; use http::StatusCode; -use hyper::service::make_service_fn; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::body_string; +use httpclient::read_body_bytes; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use hyper::service::service_fn; -use hyper::Body; -use hyper::Request; use hyper::Response; -use hyper::Server; +use hyper_util::rt::TokioIo; use itertools::Itertools; use netpod::log::*; use netpod::query::ChannelStateEventsQuery; @@ -55,43 +60,60 @@ use taskrun::tokio; use tokio::fs::File; use tokio::io::AsyncRead; use tokio::io::ReadBuf; +use tokio::net::TcpListener; use url::Url; const DISTRI_PRE: &str = "/distri/"; pub async fn proxy(proxy_config: ProxyConfig, service_version: ServiceVersion) -> Result<(), Error> { use std::str::FromStr; - let addr = SocketAddr::from_str(&format!("{}:{}", proxy_config.listen, proxy_config.port))?; - let make_service = make_service_fn({ - move |_conn| { - let proxy_config = proxy_config.clone(); - let service_version = service_version.clone(); - async move { - Ok::<_, Error>(service_fn({ - move |req| { - info!( - "http-request {:?} - {:?} - {:?} - {:?}", - addr, - req.method(), - req.uri(), - req.headers() - ); - let f = proxy_http_service(req, proxy_config.clone(), service_version.clone()); - Cont { f: Box::pin(f) } - } - })) + let bind_addr = SocketAddr::from_str(&format!("{}:{}", proxy_config.listen, proxy_config.port))?; + let listener = TcpListener::bind(bind_addr).await?; + loop { + let (stream, addr) = if let Ok(x) = listener.accept().await { + x + } else { + break; + }; + debug!("new connection from {addr}"); + let proxy_config = proxy_config.clone(); + let service_version = service_version.clone(); + let io = TokioIo::new(stream); + tokio::task::spawn(async move { + let res = hyper::server::conn::http1::Builder::new() + .serve_connection( + io, + service_fn({ + move |req| { + info!( + "http-request {:?} - {:?} - {:?} - {:?}", + bind_addr, + req.method(), + req.uri(), + req.headers() + ); + let f = proxy_http_service(req, proxy_config.clone(), service_version.clone()); + Cont { f: Box::pin(f) } + } + }), + ) + .await; + match res { + Ok(()) => {} + Err(e) => { + error!("{e}"); + } } - } - }); - Server::bind(&addr).serve(make_service).await?; + }); + } Ok(()) } async fn proxy_http_service( - req: Request, + req: Requ, proxy_config: ProxyConfig, service_version: ServiceVersion, -) -> Result, Error> { +) -> Result { match proxy_http_service_try(req, &proxy_config, &service_version).await { Ok(k) => Ok(k), Err(e) => { @@ -102,10 +124,10 @@ async fn proxy_http_service( } async fn proxy_http_service_try( - req: Request, + req: Requ, proxy_config: &ProxyConfig, service_version: &ServiceVersion, -) -> Result, Error> { +) -> Result { let ctx = ReqCtx::with_proxy(&req, proxy_config); let mut res = proxy_http_service_inner(req, &ctx, proxy_config, &service_version).await?; let hm = res.headers_mut(); @@ -119,11 +141,11 @@ async fn proxy_http_service_try( } async fn proxy_http_service_inner( - req: Request, + req: Requ, ctx: &ReqCtx, proxy_config: &ProxyConfig, service_version: &ServiceVersion, -) -> Result, Error> { +) -> Result { let uri = req.uri().clone(); let path = uri.path(); if path == "/api/1/channels" { @@ -141,9 +163,9 @@ async fn proxy_http_service_inner( "patch": service_version.patch, }, }); - Ok(response(StatusCode::OK).body(Body::from(serde_json::to_vec(&ret)?))?) + Ok(response(StatusCode::OK).body(ToJsonBody::from(&ret).into_body())?) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } else if let Some(h) = api4::StatusNodesRecursive::handler(&req) { h.handle(req, ctx, &proxy_config, service_version).await @@ -169,34 +191,34 @@ async fn proxy_http_service_inner( if req.method() == Method::GET { Ok(api_1_docs(path)?) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } else if path.starts_with("/api/4/documentation/") { if req.method() == Method::GET { Ok(api_4_docs(path)?) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } else if path.starts_with("/api/4/test/http/204") { - Ok(response(StatusCode::NO_CONTENT).body(Body::from("No Content"))?) + Ok(response(StatusCode::NO_CONTENT).body(body_string("No Content"))?) } else if path.starts_with("/api/4/test/http/400") { - Ok(response(StatusCode::BAD_REQUEST).body(Body::from("Bad Request"))?) + Ok(response(StatusCode::BAD_REQUEST).body(body_string("Bad Request"))?) } else if path.starts_with("/api/4/test/http/405") { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::from("Method Not Allowed"))?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_string("Method Not Allowed"))?) } else if path.starts_with("/api/4/test/http/406") { - Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::from("Not Acceptable"))?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_string("Not Acceptable"))?) } else if path.starts_with("/api/4/test/log/error") { error!("{path}"); - Ok(response(StatusCode::OK).body(Body::empty())?) + Ok(response(StatusCode::OK).body(body_empty())?) } else if path.starts_with("/api/4/test/log/warn") { warn!("{path}"); - Ok(response(StatusCode::OK).body(Body::empty())?) + Ok(response(StatusCode::OK).body(body_empty())?) } else if path.starts_with("/api/4/test/log/info") { info!("{path}"); - Ok(response(StatusCode::OK).body(Body::empty())?) + Ok(response(StatusCode::OK).body(body_empty())?) } else if path.starts_with("/api/4/test/log/debug") { debug!("{path}"); - Ok(response(StatusCode::OK).body(Body::empty())?) + Ok(response(StatusCode::OK).body(body_empty())?) } else if let Some(h) = api1::PythonDataApi1Query::handler(&req) { h.handle(req, ctx, proxy_config).await } else if let Some(h) = api1::reqstatus::RequestStatusHandler::handler(&req) { @@ -218,11 +240,11 @@ async fn proxy_http_service_inner( write!(out, "HEADER {hn:?}: {hv:?}
\n")?; } write!(out, "\n")?; - Ok(response(StatusCode::NOT_FOUND).body(Body::from(body))?) + Ok(response(StatusCode::NOT_FOUND).body(body_string(body))?) } } -pub async fn proxy_distribute_v2(req: Request) -> Result, Error> { +pub async fn proxy_distribute_v2(req: Requ) -> Result { let path = req.uri().path(); if path .chars() @@ -233,9 +255,9 @@ pub async fn proxy_distribute_v2(req: Request) -> Result, E let s = FileStream { file: File::open(format!("/opt/distri/{}", &path[DISTRI_PRE.len()..])).await?, }; - Ok(response(StatusCode::OK).body(Body::wrap_stream(s))?) + Ok(response(StatusCode::OK).body(body_stream(s))?) } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } @@ -276,14 +298,14 @@ pub struct BackendsResponse { backends: Vec, } -pub async fn backends(_req: Request, proxy_config: &ProxyConfig) -> Result, Error> { +pub async fn backends(_req: Requ, proxy_config: &ProxyConfig) -> Result { let backends: Vec<_> = proxy_config.backends.iter().map(|k| k.name.to_string()).collect(); let res = BackendsResponse { backends }; - let ret = response(StatusCode::OK).body(Body::from(serde_json::to_vec(&res)?))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&res).into_body())?; Ok(ret) } -pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> Result, Error> { +pub async fn channel_search(req: Requ, proxy_config: &ProxyConfig) -> Result { let (head, _body) = req.into_parts(); match head.headers.get(http::header::ACCEPT) { Some(v) => { @@ -331,13 +353,18 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R }; let qs = serde_json::to_string(&q).unwrap(); methods.push(http::Method::POST); - bodies.push(Some(Body::from(qs))); + bodies.push(Some(qs)); }); } let tags = urls.iter().map(|k| k.to_string()).collect(); - let nt = |tag, res| { + // let nt = |tag: String, res: Response| { + fn fn_nt( + tag: String, + res: Response, + ) -> Pin, Error>> + Send>> { let fut = async { - let body = hyper::body::to_bytes(res).await?; + let (_head, body) = res.into_parts(); + let body = read_body_bytes(body).await?; //info!("got a result {:?}", body); let res: SubRes = match serde_json::from_slice::(&body) { @@ -408,7 +435,7 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R Ok(res) }; Box::pin(fut) as Pin + Send>> - }; + } let ft = |all: Vec<(crate::gather::Tag, Result, Error>)>| { let mut res = Vec::new(); for (_tag, j) in all { @@ -426,7 +453,7 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R let res = ChannelSearchResult { channels: res }; let res = response(StatusCode::OK) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::from(serde_json::to_string(&res)?))?; + .body(ToJsonBody::from(&res).into_body())?; Ok(res) }; // TODO gather_get_json_generic must for this case accept a Method for each Request. @@ -438,25 +465,25 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R urls, bodies, tags, - nt, + fn_nt, ft, Duration::from_millis(3000), ) .await?; Ok(ret) } else { - Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?) } } - None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?), + None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?), } } pub async fn proxy_single_backend_query( - req: Request, + req: Requ, _ctx: &ReqCtx, proxy_config: &ProxyConfig, -) -> Result, Error> +) -> Result where QT: FromUrl + AppendToUrl + HasBackend + HasTimeout, { @@ -510,11 +537,11 @@ where a })?; let tags: Vec<_> = urls.iter().map(|k| k.to_string()).collect(); - let nt = |tag: String, res: Response| { + let nt = |tag: String, res: Response| { let fut = async { let (head, body) = res.into_parts(); if head.status == StatusCode::OK { - let body = hyper::body::to_bytes(body).await?; + let body = read_body_bytes(body).await?; match serde_json::from_slice::(&body) { Ok(val) => { let ret = SubRes { @@ -530,7 +557,7 @@ where } } } else { - let body = hyper::body::to_bytes(body).await?; + let body = read_body_bytes(body).await?; let b = String::from_utf8_lossy(&body); let ret = SubRes { tag, @@ -553,7 +580,7 @@ where // TODO want to pass arbitrary body type: let res = response(z.status) .header(http::header::CONTENT_TYPE, APP_JSON) - .body(Body::from(serde_json::to_string(&res)?))?; + .body(ToJsonBody::from(&res).into_body())?; return Ok(res); } Err(e) => { @@ -571,10 +598,10 @@ where gather_get_json_generic(http::Method::GET, urls, bodies, tags, nt, ft, query.timeout()).await?; Ok(ret) } else { - Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?) + Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?) } } - None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?), + None => Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?), } } diff --git a/crates/httpret/src/proxy/api1.rs b/crates/httpret/src/proxy/api1.rs index d5e3ef9..73c9bdd 100644 --- a/crates/httpret/src/proxy/api1.rs +++ b/crates/httpret/src/proxy/api1.rs @@ -3,13 +3,20 @@ pub mod reqstatus; use crate::bodystream::response; use crate::err::Error; use crate::ReqCtx; +use http::header; use http::HeaderValue; use http::Method; use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; -use hyper::Client; +use http::Uri; +use httpclient::body_bytes; +use httpclient::body_empty; +use httpclient::body_stream; +use httpclient::connect_client; +use httpclient::read_body_bytes; +use httpclient::Requ; +use httpclient::StreamIncoming; +use httpclient::StreamResponse; use netpod::log::*; use netpod::query::api1::Api1Query; use netpod::ProxyConfig; @@ -23,7 +30,7 @@ impl PythonDataApi1Query { "/api/1/query" } - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == Self::path() { Some(Self {}) } else { @@ -31,14 +38,9 @@ impl PythonDataApi1Query { } } - pub async fn handle( - &self, - req: Request, - _ctx: &ReqCtx, - proxy_config: &ProxyConfig, - ) -> Result, Error> { + pub async fn handle(&self, req: Requ, _ctx: &ReqCtx, proxy_config: &ProxyConfig) -> Result { if req.method() != Method::POST { - return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?); + return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?); } let (head, body) = req.into_parts(); let _accept = head @@ -47,7 +49,7 @@ impl PythonDataApi1Query { .map_or(Ok(ACCEPT_ALL), |k| k.to_str()) .map_err(|e| Error::with_msg_no_trace(format!("{e:?}")))? .to_owned(); - let body_data = hyper::body::to_bytes(body).await?; + let body_data = read_body_bytes(body).await?; if body_data.len() < 512 && body_data.first() == Some(&"{".as_bytes()[0]) { info!("request body_data string: {}", String::from_utf8_lossy(&body_data)); } @@ -73,24 +75,28 @@ impl PythonDataApi1Query { if let Some(back) = back { let url_str = format!("{}/api/1/query", back.url); info!("try to ask {url_str}"); + let uri: Uri = url_str.parse()?; let req = Request::builder() .method(Method::POST) - .uri(url_str) - .body(Body::from(body_data))?; - let client = Client::new(); - let res = client.request(req).await?; + .header(header::HOST, uri.host().unwrap()) + .uri(&uri) + .body(body_bytes(body_data))?; + let mut client = connect_client(&uri).await?; + let res = client.send_request(req).await?; let (head, body) = res.into_parts(); if head.status != StatusCode::OK { error!("backend returned error: {head:?}"); - Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(Body::empty())?) + Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(body_empty())?) } else { info!("backend returned OK"); let riq_def = HeaderValue::from_static("(none)"); let riq = head.headers.get(X_DAQBUF_REQID).unwrap_or(&riq_def); - Ok(response(StatusCode::OK).header(X_DAQBUF_REQID, riq).body(body)?) + Ok(response(StatusCode::OK) + .header(X_DAQBUF_REQID, riq) + .body(body_stream(StreamIncoming::new(body)))?) } } else { - Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(Body::empty())?) + Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(body_empty())?) } } } diff --git a/crates/httpret/src/proxy/api1/reqstatus.rs b/crates/httpret/src/proxy/api1/reqstatus.rs index c891905..9551492 100644 --- a/crates/httpret/src/proxy/api1/reqstatus.rs +++ b/crates/httpret/src/proxy/api1/reqstatus.rs @@ -1,11 +1,16 @@ use crate::bodystream::response; use crate::err::Error; +use http::header; use http::Method; use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; -use hyper::Client; +use http::Uri; +use httpclient::body_bytes; +use httpclient::body_empty; +use httpclient::connect_client; +use httpclient::read_body_bytes; +use httpclient::Requ; +use httpclient::StreamResponse; use netpod::log::*; use netpod::ProxyConfig; use netpod::ACCEPT_ALL; @@ -18,7 +23,7 @@ impl RequestStatusHandler { "/api/1/requestStatus/" } - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path().starts_with(Self::path_prefix()) { Some(Self {}) } else { @@ -26,10 +31,10 @@ impl RequestStatusHandler { } } - pub async fn handle(&self, req: Request, proxy_config: &ProxyConfig) -> Result, Error> { + pub async fn handle(&self, req: Requ, proxy_config: &ProxyConfig) -> Result { let (head, body) = req.into_parts(); if head.method != Method::GET { - return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?); + return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?); } let accept = head .headers @@ -41,9 +46,9 @@ impl RequestStatusHandler { // TODO set the public error code and message and return Err(e). let e = Error::with_public_msg_no_trace(format!("Unsupported Accept: {:?}", accept)); error!("{e}"); - return Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?); + return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } - let _body_data = hyper::body::to_bytes(body).await?; + let _body_data = read_body_bytes(body).await?; let status_id = &head.uri.path()[Self::path_prefix().len()..]; debug!("RequestStatusHandler status_id {:?}", status_id); @@ -60,22 +65,24 @@ impl RequestStatusHandler { if let Some(back) = back { let url_str = format!("{}{}{}", back.url, Self::path_prefix(), status_id); debug!("try to ask {url_str}"); + let uri: Uri = url_str.parse()?; let req = Request::builder() .method(Method::GET) - .uri(url_str) - .body(Body::empty())?; - let client = Client::new(); - let res = client.request(req).await?; + .header(header::HOST, uri.host().unwrap()) + .uri(&uri) + .body(body_empty())?; + let res = connect_client(&uri).await?.send_request(req).await?; let (head, body) = res.into_parts(); if head.status != StatusCode::OK { error!("backend returned error: {head:?}"); - Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(Body::empty())?) + Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(body_empty())?) } else { debug!("backend returned OK"); - Ok(response(StatusCode::OK).body(body)?) + let body = read_body_bytes(body).await?; + Ok(response(StatusCode::OK).body(body_bytes(body))?) } } else { - Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(Body::empty())?) + Ok(response(StatusCode::INTERNAL_SERVER_ERROR).body(body_empty())?) } } } diff --git a/crates/httpret/src/proxy/api4.rs b/crates/httpret/src/proxy/api4.rs index d21dfcc..682236a 100644 --- a/crates/httpret/src/proxy/api4.rs +++ b/crates/httpret/src/proxy/api4.rs @@ -9,9 +9,15 @@ use crate::response; use crate::ReqCtx; use futures_util::Future; use http::Method; -use http::Request; use http::Response; use http::StatusCode; +use httpclient::body_empty; +use httpclient::read_body_bytes; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; +use hyper::body::Incoming; use netpod::log::*; use netpod::ChannelSearchQuery; use netpod::ChannelSearchResult; @@ -34,7 +40,7 @@ use url::Url; // The aggregators and leaf nodes behind should as well not depend on backend, // but simply answer all matching. -pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> Result { +pub async fn channel_search(req: Requ, proxy_config: &ProxyConfig) -> Result { let (head, _body) = req.into_parts(); let inpurl = Url::parse(&format!("dummy:{}", head.uri))?; let query = ChannelSearchQuery::from_url(&inpurl)?; @@ -58,9 +64,10 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R } } } - let nt = |tag, res| { + let nt = |tag: String, res: Response| { let fut = async { - let body = hyper::body::to_bytes(res).await?; + let (_head, body) = res.into_parts(); + let body = read_body_bytes(body).await?; //info!("got a result {:?}", body); let res: ChannelSearchResult = match serde_json::from_slice(&body) { Ok(k) => k, @@ -112,7 +119,7 @@ pub async fn channel_search(req: Request, proxy_config: &ProxyConfig) -> R pub struct ChannelSearchAggHandler {} impl ChannelSearchAggHandler { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == "/api/4/search/channel" { Some(Self {}) } else { @@ -120,7 +127,7 @@ impl ChannelSearchAggHandler { } } - pub async fn handle(&self, req: Request, node_config: &ProxyConfig) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &ProxyConfig) -> Result { if req.method() == Method::GET { let accept_def = APP_JSON; let accept = req @@ -129,20 +136,17 @@ impl ChannelSearchAggHandler { .map_or(accept_def, |k| k.to_str().unwrap_or(accept_def)); if accept.contains(APP_JSON) || accept.contains(ACCEPT_ALL) { match channel_search(req, node_config).await { - Ok(item) => { - let buf = serde_json::to_vec(&item)?; - Ok(response(StatusCode::OK).body(Body::from(buf))?) - } + Ok(item) => Ok(response(StatusCode::OK).body(ToJsonBody::from(&item).into_body())?), Err(e) => { warn!("ChannelConfigHandler::handle: got error from channel_config: {e:?}"); Ok(e.to_public_response()) } } } else { - Ok(response(StatusCode::BAD_REQUEST).body(Body::empty())?) + Ok(response(StatusCode::BAD_REQUEST).body(body_empty())?) } } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } } @@ -150,7 +154,7 @@ impl ChannelSearchAggHandler { pub struct StatusNodesRecursive {} impl StatusNodesRecursive { - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == crate::api4::status::StatusNodesRecursive::path() { Some(Self {}) } else { @@ -160,15 +164,14 @@ impl StatusNodesRecursive { pub async fn handle( &self, - req: Request, + req: Requ, ctx: &ReqCtx, proxy_config: &ProxyConfig, service_version: &ServiceVersion, - ) -> Result, Error> { + ) -> Result { match self.status(req, ctx, proxy_config, service_version).await { Ok(status) => { - let body = serde_json::to_vec(&status)?; - let ret = response(StatusCode::OK).body(Body::from(body))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&status).into_body())?; Ok(ret) } Err(e) => { @@ -181,7 +184,7 @@ impl StatusNodesRecursive { async fn status( &self, - _req: Request, + _req: Requ, _ctx: &ReqCtx, proxy_config: &ProxyConfig, service_version: &ServiceVersion, @@ -200,9 +203,10 @@ impl StatusNodesRecursive { Err(e) => return Err(Error::with_msg_no_trace(format!("parse error for: {sub:?} {e:?}"))), } } - let nt = |tag, res| { + let nt = |tag: String, res: Response| { let fut = async { - let body = hyper::body::to_bytes(res).await?; + let (_head, body) = res.into_parts(); + let body = read_body_bytes(body).await?; let res: JsVal = match serde_json::from_slice(&body) { Ok(k) => k, Err(e) => { diff --git a/crates/httpret/src/proxy/api4/caioclookup.rs b/crates/httpret/src/proxy/api4/caioclookup.rs index 105c654..a9a7325 100644 --- a/crates/httpret/src/proxy/api4/caioclookup.rs +++ b/crates/httpret/src/proxy/api4/caioclookup.rs @@ -1,10 +1,11 @@ use crate::bodystream::response; use crate::err::Error; use crate::ReqCtx; -use http::Request; -use http::Response; use http::StatusCode; -use hyper::Body; +use httpclient::IntoBody; +use httpclient::Requ; +use httpclient::StreamResponse; +use httpclient::ToJsonBody; use netpod::log::*; use netpod::ProxyConfig; @@ -15,7 +16,7 @@ impl CaIocLookup { "/api/4/channel-access/search/addr" } - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path() == Self::path() { Some(Self {}) } else { @@ -23,16 +24,10 @@ impl CaIocLookup { } } - pub async fn handle( - &self, - req: Request, - ctx: &ReqCtx, - node_config: &ProxyConfig, - ) -> Result, Error> { + pub async fn handle(&self, req: Requ, ctx: &ReqCtx, node_config: &ProxyConfig) -> Result { match self.search(req, ctx, node_config).await { Ok(status) => { - let body = serde_json::to_vec(&status)?; - let ret = response(StatusCode::OK).body(Body::from(body))?; + let ret = response(StatusCode::OK).body(ToJsonBody::from(&status).into_body())?; Ok(ret) } Err(e) => { @@ -43,12 +38,7 @@ impl CaIocLookup { } } - async fn search( - &self, - _req: Request, - _ctx: &ReqCtx, - _proxy_config: &ProxyConfig, - ) -> Result, Error> { + async fn search(&self, _req: Requ, _ctx: &ReqCtx, _proxy_config: &ProxyConfig) -> Result, Error> { Ok(None) } } diff --git a/crates/httpret/src/pulsemap.rs b/crates/httpret/src/pulsemap.rs index e53beaf..3223d98 100644 --- a/crates/httpret/src/pulsemap.rs +++ b/crates/httpret/src/pulsemap.rs @@ -4,7 +4,6 @@ use crate::cache::Cache; use crate::err::Error; use crate::response; use crate::Requ; -use crate::RespFull; use bytes::Buf; use bytes::BufMut; use bytes::BytesMut; @@ -19,6 +18,7 @@ use http::StatusCode; use http::Uri; use httpclient::connect_client; use httpclient::read_body_bytes; +use httpclient::StreamResponse; use hyper::Request; use netpod::log::*; use netpod::timeunits::SEC; @@ -401,7 +401,7 @@ impl IndexFullHttpFunction { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -908,7 +908,7 @@ impl MapPulseScyllaHandler { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -960,7 +960,7 @@ impl MapPulseLocalHttpFunction { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -1119,7 +1119,7 @@ impl MapPulseHistoHttpFunction { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -1210,7 +1210,7 @@ impl MapPulseHttpFunction { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { use crate::cache::CachePortal; if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); @@ -1343,7 +1343,7 @@ impl Api4MapPulseHttpFunction { res } - pub async fn handle(&self, req: Requ, ncc: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, ncc: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -1394,7 +1394,7 @@ impl Api4MapPulse2HttpFunction { path.starts_with(Self::path_prefix()) } - pub async fn handle(&self, req: Requ, ncc: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, ncc: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } @@ -1440,7 +1440,7 @@ impl MarkClosedHttpFunction { } } - pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() != Method::GET { return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } diff --git a/crates/httpret/src/settings.rs b/crates/httpret/src/settings.rs index 8170234..286a1c8 100644 --- a/crates/httpret/src/settings.rs +++ b/crates/httpret/src/settings.rs @@ -3,8 +3,10 @@ use crate::response; use http::header; use http::Method; use http::StatusCode; -use hyper::Request; -use hyper::Response; +use httpclient::body_empty; +use httpclient::body_string; +use httpclient::Requ; +use httpclient::StreamResponse; use netpod::log::*; use netpod::NodeConfigCached; use netpod::ACCEPT_ALL; @@ -17,7 +19,7 @@ impl SettingsThreadsMaxHandler { "/api/4/settings/read3/threads_max" } - pub fn handler(req: &Request) -> Option { + pub fn handler(req: &Requ) -> Option { if req.uri().path().starts_with(Self::path_prefix()) { Some(Self {}) } else { @@ -25,7 +27,7 @@ impl SettingsThreadsMaxHandler { } } - pub async fn put(&self, req: Request, _node_config: &NodeConfigCached) -> Result, Error> { + pub async fn put(&self, req: Requ, _node_config: &NodeConfigCached) -> Result { let (head, body) = req.into_parts(); let accept = head .headers @@ -35,32 +37,32 @@ impl SettingsThreadsMaxHandler { .to_owned(); if accept != APP_JSON && accept != ACCEPT_ALL { // TODO set the public error code and message and return Err(e). - let e = Error::with_public_msg_no_trace(format!("Unsupported Accept: {:?}", accept)); + let e = Error::with_public_msg_no_trace(format!("unsupported accept: {:?}", accept)); error!("{e}"); - return Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?); + return Ok(response(StatusCode::NOT_ACCEPTABLE).body(body_empty())?); } let body = httpclient::read_body_bytes(body).await?; //let threads_max: usize = head.uri.path()[Self::path_prefix().len()..].parse()?; let threads_max: usize = String::from_utf8_lossy(&body).parse()?; info!("threads_max {threads_max}"); disk::read3::Read3::get().set_threads_max(threads_max); - let ret = response(StatusCode::NO_CONTENT).body(Body::empty())?; + let ret = response(StatusCode::NO_CONTENT).body(body_empty())?; Ok(ret) } - pub async fn get(&self, _req: Request, _node_config: &NodeConfigCached) -> Result, Error> { + pub async fn get(&self, _req: Requ, _node_config: &NodeConfigCached) -> Result { let threads_max = disk::read3::Read3::get().threads_max(); - let ret = response(StatusCode::OK).body(Body::from(format!("{threads_max}")))?; + let ret = response(StatusCode::OK).body(body_string(format!("{threads_max}")))?; Ok(ret) } - pub async fn handle(&self, req: Request, node_config: &NodeConfigCached) -> Result, Error> { + pub async fn handle(&self, req: Requ, node_config: &NodeConfigCached) -> Result { if req.method() == Method::GET { self.get(req, node_config).await } else if req.method() == Method::PUT { self.put(req, node_config).await } else { - Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?) + Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?) } } } diff --git a/crates/streams/src/tcprawclient.rs b/crates/streams/src/tcprawclient.rs index d1b6e41..9aa48ac 100644 --- a/crates/streams/src/tcprawclient.rs +++ b/crates/streams/src/tcprawclient.rs @@ -8,6 +8,9 @@ use crate::frames::inmem::InMemoryFrameStream; use crate::frames::inmem::TcpReadAsBytes; use err::Error; use futures_util::Stream; +use http::Uri; +use httpclient::body_bytes; +use httpclient::http; use items_0::framable::FrameTypeInnerStatic; use items_0::streamitem::sitem_data; use items_0::streamitem::Sitemty; @@ -62,21 +65,22 @@ pub async fn x_processed_event_blobs_stream_from_node_http( use http::header; use http::Method; use http::Request; - use httpclient::http; use httpclient::hyper; use hyper::StatusCode; let frame1 = make_node_command_frame(subq.clone())?; let item = sitem_data(frame1.clone()); - let buf = item.make_frame()?.freeze(); + let buf = item.make_frame()?; let url = node.baseurl().join("/api/4/private/eventdata/frames").unwrap(); debug!("open_event_data_streams_http post {url}"); + let uri: Uri = url.as_str().parse().unwrap(); let req = Request::builder() .method(Method::POST) - .uri(url.to_string()) + .uri(&uri) + .header(header::HOST, uri.host().unwrap()) .header(header::ACCEPT, APP_OCTET) - .body(httpclient::Full::new(buf)) + .body(body_bytes(buf)) .map_err(|e| Error::with_msg_no_trace(e.to_string()))?; let mut client = httpclient::connect_client(req.uri()).await?; let res = client @@ -161,20 +165,20 @@ where use http::header; use http::Method; use http::Request; - use httpclient::http; - use httpclient::hyper; - use hyper::StatusCode; + use httpclient::hyper::StatusCode; let item = sitem_data(frame1.clone()); - let buf = item.make_frame()?.freeze(); + let buf = item.make_frame()?; let url = node.baseurl().join("/api/4/private/eventdata/frames").unwrap(); debug!("open_event_data_streams_http post {url}"); + let uri: Uri = url.as_str().parse().unwrap(); let req = Request::builder() .method(Method::POST) - .uri(url.to_string()) + .uri(&uri) + .header(header::HOST, uri.host().unwrap()) .header(header::ACCEPT, APP_OCTET) - .body(httpclient::Full::new(buf)) + .body(body_bytes(buf)) .map_err(|e| Error::with_msg_no_trace(e.to_string()))?; let mut client = httpclient::connect_client(req.uri()).await?; let res = client