config: config::Opts,
}
+const METADATA_MAX_LEN: usize = MAX_OVERHEAD;
async fn handle(
// context: (),
req: hyper::Request<hyper::Body>
) -> Result<hyper::Response<hyper::Body>, Infallible> {
+ let mkboundary = |b: &'_ _| format!("\n--{}", b).into_bytes();
let (boundary, warning) = (||{
let mut ctypes = req.headers().get_all("Content-Type").iter();
let t = ctypes.next().ok_or_else(|| anyhow!("missing Content-Type"))?;
if t.subtype() != "form-data" { throw!(anyhow!("not /form-data"))}
Ok::<_,AE>(())
})();
- Ok::<_,AE>((b.as_str().to_owned(), warning))
+ let b = mkboundary(b.as_str());
+ Ok::<_,AE>((b, warning))
})().unwrap_or_else(|e| {
- ("b".into(), Err(e.wrap_err("guessing boundary")))
+ (mkboundary("b"), Err(e.wrap_err("guessing boundary")))
});
- eprintln!("boundary={}", boundary);
if let Err(w) = &warning { eprintln!("warning={}", w); }
+ match async {
+ let mut body = req.into_body();
+ let initial = match read_limited_bytes(METADATA_MAX_LEN, &mut body).await {
+ Ok(all) => all,
+ Err(ReadLimitedError::Truncated { sofar,.. }) => sofar,
+ Err(ReadLimitedError::Hyper(e)) => throw!(e),
+ };
+
+ eprintln!("boundary={:?} initial={:?}", boundary, initial);
+
+ Ok::<_,AE>(())
+ }.await {
+ Ok(()) => {
+ },
+ Err(e) => {
+ eprintln!("error={}", e);
+ }
+ }
Ok(hyper::Response::new(hyper::Body::from("Hello World")))
}