Replaced ureq_multipart
with multipart-rs
The latter seems maintained and does provide a license, unlike the former.
This commit is contained in:
parent
0f6b2b214a
commit
fc964074d3
113
Cargo.lock
generated
113
Cargo.lock
generated
|
@ -2748,6 +2748,20 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "multipart-rs"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "22ea34e5c0fa65ba84707cfaf5bf43d500f1c5a4c6c36327bf5541c5bcd17e98"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"memchr",
|
||||||
|
"mime",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multiversion"
|
name = "multiversion"
|
||||||
version = "0.7.4"
|
version = "0.7.4"
|
||||||
|
@ -2877,6 +2891,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"miette",
|
"miette",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"multipart-rs",
|
||||||
"nix",
|
"nix",
|
||||||
"nu-cli",
|
"nu-cli",
|
||||||
"nu-cmd-base",
|
"nu-cmd-base",
|
||||||
|
@ -2908,7 +2923,6 @@ dependencies = [
|
||||||
"tango-bench",
|
"tango-bench",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"time",
|
"time",
|
||||||
"ureq_multipart",
|
|
||||||
"winresource",
|
"winresource",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3065,6 +3079,7 @@ dependencies = [
|
||||||
"mime",
|
"mime",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"mockito",
|
"mockito",
|
||||||
|
"multipart-rs",
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"nix",
|
"nix",
|
||||||
"notify-debouncer-full",
|
"notify-debouncer-full",
|
||||||
|
@ -3122,7 +3137,6 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"ureq",
|
"ureq",
|
||||||
"ureq_multipart",
|
|
||||||
"url",
|
"url",
|
||||||
"uu_cp",
|
"uu_cp",
|
||||||
"uu_mkdir",
|
"uu_mkdir",
|
||||||
|
@ -5106,21 +5120,6 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.17.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"cfg-if",
|
|
||||||
"getrandom",
|
|
||||||
"libc",
|
|
||||||
"spin",
|
|
||||||
"untrusted",
|
|
||||||
"windows-sys 0.52.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rkyv"
|
name = "rkyv"
|
||||||
version = "0.7.44"
|
version = "0.7.44"
|
||||||
|
@ -5331,38 +5330,6 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls"
|
|
||||||
version = "0.23.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
|
||||||
"ring",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"rustls-webpki",
|
|
||||||
"subtle",
|
|
||||||
"zeroize",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls-pki-types"
|
|
||||||
version = "1.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustls-webpki"
|
|
||||||
version = "0.102.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e"
|
|
||||||
dependencies = [
|
|
||||||
"ring",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"untrusted",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
|
@ -5786,12 +5753,6 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.9.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sqlparser"
|
name = "sqlparser"
|
||||||
version = "0.47.0"
|
version = "0.47.0"
|
||||||
|
@ -5926,12 +5887,6 @@ dependencies = [
|
||||||
"syn 2.0.60",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "subtle"
|
|
||||||
version = "2.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "supports-color"
|
name = "supports-color"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -6543,12 +6498,6 @@ version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "untrusted"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ureq"
|
name = "ureq"
|
||||||
version = "2.10.0"
|
version = "2.10.0"
|
||||||
|
@ -6561,24 +6510,9 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"url",
|
"url",
|
||||||
"webpki-roots",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ureq_multipart"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "22baf2d124865fc4d505f5942222a57f6a3eae8a133819d7fd6194423e3f6e91"
|
|
||||||
dependencies = [
|
|
||||||
"mime",
|
|
||||||
"mime_guess",
|
|
||||||
"rand",
|
|
||||||
"ureq",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -6984,15 +6918,6 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "webpki-roots"
|
|
||||||
version = "0.26.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd"
|
|
||||||
dependencies = [
|
|
||||||
"rustls-pki-types",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "which"
|
name = "which"
|
||||||
version = "6.0.1"
|
version = "6.0.1"
|
||||||
|
@ -7448,12 +7373,6 @@ dependencies = [
|
||||||
"syn 2.0.60",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zeroize"
|
|
||||||
version = "1.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zip"
|
name = "zip"
|
||||||
version = "0.6.6"
|
version = "0.6.6"
|
||||||
|
|
|
@ -113,6 +113,7 @@ miette = "7.2"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
mime_guess = "2.0"
|
mime_guess = "2.0"
|
||||||
mockito = { version = "1.4", default-features = false }
|
mockito = { version = "1.4", default-features = false }
|
||||||
|
multipart-rs = "0.1.11"
|
||||||
native-tls = "0.2"
|
native-tls = "0.2"
|
||||||
nix = { version = "0.28", default-features = false }
|
nix = { version = "0.28", default-features = false }
|
||||||
notify-debouncer-full = { version = "0.3", default-features = false }
|
notify-debouncer-full = { version = "0.3", default-features = false }
|
||||||
|
@ -166,7 +167,6 @@ umask = "2.1"
|
||||||
unicode-segmentation = "1.11"
|
unicode-segmentation = "1.11"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.1"
|
||||||
ureq = { version = "2.10", default-features = false }
|
ureq = { version = "2.10", default-features = false }
|
||||||
ureq_multipart = "1.1.1"
|
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
uu_cp = "0.0.27"
|
uu_cp = "0.0.27"
|
||||||
uu_mkdir = "0.0.27"
|
uu_mkdir = "0.0.27"
|
||||||
|
@ -208,10 +208,10 @@ dirs = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] }
|
miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] }
|
||||||
mimalloc = { version = "0.1.42", default-features = false, optional = true }
|
mimalloc = { version = "0.1.42", default-features = false, optional = true }
|
||||||
|
multipart-rs = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
simplelog = "0.12"
|
simplelog = "0.12"
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
ureq_multipart = { workspace = true }
|
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
||||||
# Our dependencies don't use OpenSSL on Windows
|
# Our dependencies don't use OpenSSL on Windows
|
||||||
|
|
|
@ -60,6 +60,7 @@ lscolors = { workspace = true, default-features = false, features = ["nu-ansi-te
|
||||||
md5 = { workspace = true }
|
md5 = { workspace = true }
|
||||||
mime = { workspace = true }
|
mime = { workspace = true }
|
||||||
mime_guess = { workspace = true }
|
mime_guess = { workspace = true }
|
||||||
|
multipart-rs = { workspace = true }
|
||||||
native-tls = { workspace = true }
|
native-tls = { workspace = true }
|
||||||
notify-debouncer-full = { workspace = true, default-features = false }
|
notify-debouncer-full = { workspace = true, default-features = false }
|
||||||
num-format = { workspace = true }
|
num-format = { workspace = true }
|
||||||
|
@ -90,7 +91,6 @@ titlecase = { workspace = true }
|
||||||
toml = { workspace = true, features = ["preserve_order"]}
|
toml = { workspace = true, features = ["preserve_order"]}
|
||||||
unicode-segmentation = { workspace = true }
|
unicode-segmentation = { workspace = true }
|
||||||
ureq = { workspace = true, default-features = false, features = ["charset", "gzip", "json", "native-tls"] }
|
ureq = { workspace = true, default-features = false, features = ["charset", "gzip", "json", "native-tls"] }
|
||||||
ureq_multipart = { workspace = true }
|
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
uu_cp = { workspace = true }
|
uu_cp = { workspace = true }
|
||||||
uu_mkdir = { workspace = true }
|
uu_mkdir = { workspace = true }
|
||||||
|
|
|
@ -4,6 +4,7 @@ use base64::{
|
||||||
engine::{general_purpose::PAD, GeneralPurpose},
|
engine::{general_purpose::PAD, GeneralPurpose},
|
||||||
Engine,
|
Engine,
|
||||||
};
|
};
|
||||||
|
use multipart_rs::MultipartWriter;
|
||||||
use nu_engine::command_prelude::*;
|
use nu_engine::command_prelude::*;
|
||||||
use nu_protocol::{ByteStream, Signals};
|
use nu_protocol::{ByteStream, Signals};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -15,7 +16,6 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use ureq::{Error, ErrorKind, Request, Response};
|
use ureq::{Error, ErrorKind, Request, Response};
|
||||||
use ureq_multipart::MultipartBuilder;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
|
@ -271,7 +271,7 @@ pub fn send_request(
|
||||||
}
|
}
|
||||||
// multipart form upload
|
// multipart form upload
|
||||||
Value::Record { val, .. } if body_type == BodyType::Multipart => {
|
Value::Record { val, .. } if body_type == BodyType::Multipart => {
|
||||||
let mut builder = MultipartBuilder::new();
|
let mut builder = MultipartWriter::new();
|
||||||
|
|
||||||
let err = |e| {
|
let err = |e| {
|
||||||
ShellErrorOrRequestError::ShellError(ShellError::IOError {
|
ShellErrorOrRequestError::ShellError(ShellError::IOError {
|
||||||
|
@ -281,17 +281,26 @@ pub fn send_request(
|
||||||
|
|
||||||
for (col, val) in val.into_owned() {
|
for (col, val) in val.into_owned() {
|
||||||
if let Value::Binary { val, .. } = val {
|
if let Value::Binary { val, .. } = val {
|
||||||
builder = builder
|
let headers = format!(
|
||||||
.add_stream(&mut Cursor::new(val), &col, Some(&col), None)
|
r#"Content-Type: application/octet-stream
|
||||||
.map_err(err)?;
|
Content-Disposition: form-data; name="{}"; filename="{}"
|
||||||
|
Content-Transfer-Encoding: binary
|
||||||
|
"#,
|
||||||
|
col, col,
|
||||||
|
);
|
||||||
|
builder.add(&mut Cursor::new(val), &headers).map_err(err)?;
|
||||||
} else {
|
} else {
|
||||||
builder = builder
|
let headers =
|
||||||
.add_text(&col, &val.coerce_into_string()?)
|
format!(r#"Content-Disposition: form-data; name="{}""#, col,);
|
||||||
|
builder
|
||||||
|
.add(val.coerce_into_string()?.as_bytes(), &headers)
|
||||||
.map_err(err)?;
|
.map_err(err)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
builder.finish();
|
||||||
|
|
||||||
let (content_type, data) = builder.finish().map_err(err)?;
|
let (boundary, data) = (builder.boundary, builder.data);
|
||||||
|
let content_type = format!("multipart/form-data; boundary={}", boundary);
|
||||||
|
|
||||||
let request_fn =
|
let request_fn =
|
||||||
move || req.set("Content-Type", &content_type).send_bytes(&data);
|
move || req.set("Content-Type", &content_type).send_bytes(&data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user