From: Ian Jackson Date: Sat, 31 Jul 2021 18:10:27 +0000 (+0100) Subject: wip request mime X-Git-Tag: hippotat/1.0.0~411 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=32fe11f5d4ee18537838c6f2d80add19d82e75fd;p=hippotat.git wip request mime Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index ba31196..2075448 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -29,7 +29,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( .saturating_add(Duration::from_nanos(999_999_999)) .as_secs(); - let prefix = format!(into_crlfs!( + let prefix1 = format!(into_crlfs!( r#"-- Content-Type: text/plain; charset="utf-8" Content-Disposition: form-data; name="m" @@ -57,15 +57,21 @@ fn submit_request<'r, 'c:'r, C:HCC>( --b-- "#), ); -eprintln!(">{}[{}D]{}<", &prefix, &prefix2, &suffix); let body = hyper::body::Body::wrap_stream( - futures::stream::iter( + futures::stream::iter(itertools::chain![ + array::IntoIter::new([ + Ok::( prefix1.into() ), + Ok::( prefix2.into() ), + ]).take( + if upbound.is_empty() { 1 } else { 2 } + ), Itertools::intersperse( upbound.into_iter().map(|u| Bytes::from(u)), SLIP_END_SLICE.into() - ).map(Ok::<_,Void>) - ) + ).map(Ok::), + [ Ok::( suffix.into() ) ], + ]) ); let req = hyper::Request::post(&c.ic.url).body(body) diff --git a/src/prelude.rs b/src/prelude.rs index b23be67..8794519 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // There is NO WARRANTY. +pub use std::array; pub use std::collections::{BTreeSet, HashMap}; pub use std::convert::TryInto; pub use std::borrow::Cow;