diff --git a/Cargo.lock b/Cargo.lock index c1df983..839b0b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,9 +149,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "bumpalo" @@ -374,7 +374,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "crossterm_winapi", "mio 1.0.2", "parking_lot", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" dependencies = [ "litrs", ] @@ -498,12 +498,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -780,6 +780,7 @@ dependencies = [ "inquire", "jsonpath", "log", + "mime", "mktemp", "notify", "ratatui", @@ -789,7 +790,7 @@ dependencies = [ "syntect", "syntect-tui", "termcolor", - "thiserror 2.0.3", + "thiserror 2.0.18", "tokio", "toml", "tui-input", @@ -1118,7 +1119,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "chrono", "crossterm 0.25.0", "dyn-clone", @@ -1230,9 +1231,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libredox" @@ -1240,7 +1241,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "libc", "redox_syscall", ] @@ -1265,9 +1266,9 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "litrs" -version = "0.4.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" [[package]] name = "lock_api" @@ -1381,7 +1382,7 @@ version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c533b4c39709f9ba5005d8002048266593c1cfaf3c5f0739d5b8ab0c6c504009" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "filetime", "fsevent-sys", "inotify", @@ -1461,7 +1462,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "cfg-if", "foreign-types", "libc", @@ -1653,7 +1654,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "cassowary", "compact_str", "crossterm 0.28.1", @@ -1674,7 +1675,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", ] [[package]] @@ -1757,7 +1758,7 @@ version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys", @@ -1845,7 +1846,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "core-foundation", "core-foundation-sys", "libc", @@ -2130,7 +2131,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.11.0", "core-foundation", "system-configuration-sys", ] @@ -2178,11 +2179,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.18", ] [[package]] @@ -2198,9 +2199,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote 1.0.37", diff --git a/Cargo.toml b/Cargo.toml index bb9a8a2..4a697a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ tui-input = "0.11.0" syntect-tui = "3.0.4" syntect = "5.2.0" graphql-parser = "0.4.0" +mime = "0.3.17" [dev-dependencies] mktemp = "0.5.1" diff --git a/src/request.rs b/src/request.rs index a806a10..d92ff3a 100644 --- a/src/request.rs +++ b/src/request.rs @@ -133,17 +133,24 @@ pub async fn make_request(resolved: &Resolved, scope: &Scope) -> Result<()> { // Subscription for graphql is a stream if let Some(content_type) = response.headers().get(CONTENT_TYPE) { - if content_type.to_str()?.contains("text/event-stream") { - return parse_stream_output(response).await; + let mime = mime::Mime::from_str(content_type.to_str()?)?; + match (mime.type_(), mime.subtype()) { + (mime::TEXT, mime::EVENT_STREAM) => { + return parse_stream_output(response).await; + } + (_, subtype) if subtype.as_str().contains("json") => { + let json = response.json::().await?; + println!("{}", serde_json::to_string_pretty(&json)?); + let vars = extract_variables(&json, scope)?; + update_data(&resolved.root_dir, &vars)?; + } + _ => { + let text = response.text().await?; + println!("{text}"); + } } } - if let Ok(json) = response.json::().await { - println!("{}", serde_json::to_string_pretty(&json)?); - let vars = extract_variables(&json, scope)?; - update_data(&resolved.root_dir, &vars)?; - } - warn!("# Request completed in {:.2?}", elapsed); Ok(())